Xamarin 中的边框 Class 模拟 Android
Border Class analog in Xamarin Android
我想画一个蜡烛图(500 件)。在 WPF 中,我可以在 1 个滚动查看器中使用 500 个边框 (System.Windows.Controls.Border)。
我也可以在需要时更改任何项目。
如何在 Xamarin.Android 中执行相同的操作? Xamarin.Android 不包含边框 class。
你可以使用一个 ScrollView
,其中包含一个 LinearLayout
,它本身是一个简单的 <View>
的 500 倍,它具有一个大小和一个可绘制的 stroke
作为背景
类似
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
>
<View
android:layout_width="50dp"
android:layout_height="100dp"
android:background="@drawable/border_white"
/>
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/border_white"
/>
并在 res/drawable 中,一个名为 border_white
的文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dip" android:color="@android:color/white" />
</shape>
但我告诉你它会很慢(可能像 Windows)。
我想画一个蜡烛图(500 件)。在 WPF 中,我可以在 1 个滚动查看器中使用 500 个边框 (System.Windows.Controls.Border)。 我也可以在需要时更改任何项目。
如何在 Xamarin.Android 中执行相同的操作? Xamarin.Android 不包含边框 class。
你可以使用一个 ScrollView
,其中包含一个 LinearLayout
,它本身是一个简单的 <View>
的 500 倍,它具有一个大小和一个可绘制的 stroke
作为背景
类似
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
>
<View
android:layout_width="50dp"
android:layout_height="100dp"
android:background="@drawable/border_white"
/>
<View
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/border_white"
/>
并在 res/drawable 中,一个名为 border_white
的文件<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dip" android:color="@android:color/white" />
</shape>
但我告诉你它会很慢(可能像 Windows)。