我是新的Xamarin android开发。如果问题听起来很简单,请原谅。我正在创建一个表单,我需要向用户提供选择多个选项的选项,有点像复选框组。选项的数量可能会更大,例如10-20。我不是要使用哪个控件或布局,因此用户可以轻松阅读和选择选项。我尝试使用线性和垂直选项进行布局,但效果并不理想。同样如何基于某些数据源以编程方式创建那些选项。请建议我最好的设计方法。任何帮助将不胜感激。这是我的axml中的代码段
我尝试使用LinearLayout并使用了复选框控件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/blogging"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blog"/>
<CheckBox
android:id="@+id/game"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Game" />
答案 0 :(得分:0)
Found what I was looking for. It's called the Switch tool. So to provide settings page like options, I'll use this instead of checkboxes
<Switch
android:id="@+id/blogging"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Widget.AppCompat.CompoundButton.Switch"
android:hint="Blog"
/>
<Switch
android:id="@+id/game"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Widget.AppCompat.CompoundButton.Switch"
android:text="Game" />