android stdio 中两个复选框怎样才能在同一行上布局?
可以在两个的复选框的外围套一个LinearLayout 然后设置布局的方向是水平的,设置一下两个复选框的权重,就可以实现了
相对布局,帧布局,线性布局都可以实现,建议看看《第一行代码》,里面有用法介绍!
LinearLayout 不就解决了。
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".LinearLayoutActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#aa0000"
android:gravity="center_horizontal|center_vertical"
android:text="第一列"
android:textSize="15sp" >
</Button>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00aa00"
android:gravity="center_horizontal"
android:text="第二列"
android:textSize="15sp" >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom"
android:text="第1行"
android:textSize="15sp" >
</Button>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom"
android:text="第2行"
android:textSize="15sp" >
</Button>
</LinearLayout>