0
如何創建這種佈局在機器人如何創建這種佈局在機器人
---------------------
|col1 | col2 | col3 |
| col1 | col2 |
---------------------
的第一行是3列相等的寬度,並且所述第二行是2行相等的寬度。 是否可以在TableLayout中創建它? 我沒有嘗試寬度android:layout_span =「2」爲最後一個單元格,但它不會以相等的寬度結束。
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow android:layout_marginTop="6dp">
<Button
android:id="@+id/button1"
android:layout_weight="33"
android:textStyle="bold"
android:text="@string/percent" />
<Button
android:id="@+id/button2"
android:layout_weight="33"
android:textStyle="bold"
android:text="@string/percent" />
<Button
android:id="@+id/button8"
android:layout_weight="33"
android:textStyle="bold"
android:text="@string/percent" />
</TableRow>
<TableRow android:layout_marginTop="6dp">
<Button
android:id="@+id/button3"
android:layout_weight="60"
android:textStyle="bold"
android:text="@string/percent" />
<Button
android:id="@+id/button4"
android:layout_weight="40"
android:layout_span="2"
android:textStyle="bold"
android:text="@string/percent" />
</TableRow>
</TableLayout>
你嘗試使用兩個TableLayouts?我的意思是將您的根佈局更改爲RelativeLayout,然後添加兩個TableLayouts,一個處理3列,另一個處理2列。 – dumbfingers
提示:在** LinearLayout *內部使用**權重**,並且易於實現... – waqaslam
您使用layout_weight 60和40作爲第二個表格行上的兩個組件。使用50和50 –