Android 水平显示复选框
是否可以水平显示复选框而不是垂直显示复选框,类似于单选按钮上显示的选项?是的,如何做到这一点呢?是的,将它们包装成一个线性布局,给每个布局赋予权重,然后在一行中添加任意数量的内容。。虽然在某个时间点,他们会开始挤在一起,你不应该那样做Android 水平显示复选框,android,Android,是否可以水平显示复选框而不是垂直显示复选框,类似于单选按钮上显示的选项?是的,如何做到这一点呢?是的,将它们包装成一个线性布局,给每个布局赋予权重,然后在一行中添加任意数量的内容。。虽然在某个时间点,他们会开始挤在一起,你不应该那样做 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/checkBox"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="CheckBox" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="CheckBox" />
//Copy Paste More CheckBoxes...
</LinearLayout>
</LinearLayout>
如果您在LinearLayout中有该复选框,您可以在LinearLayout属性中使用android:orientation=Horizone将布局设置为水平,LinearLayout中的所有元素都将显示HorizontallThank谢谢您的说明。谢谢您的示例。