效果:
源码:
<TableLayout android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"
android:shrinkColumns="1,2"
android:stretchColumns="1">
<Button
android:text="按钮1"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
<TableRow>
<Button
android:text="按钮1"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
<Button
android:text="按钮2"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
<Button
android:text="按钮3"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
</TableRow>
</TableLayout>
通过< T a b l e R o w > <TableRow><TableRow>来进行一行行的填充 android:shrinkColumns="1,2"代表显示不下时会压缩该行第1,2个格子的内容(格子标号从0开始) android:stretchColumns=“1”>代表有剩余空间时会拓展第1个各自的内容