表格布局是一个ViewGroup以表格显示它的子视图(view)元素,即行和列标识一个视图的位置。Android的表格布局跟HTML中的表格布局非常类似,TableRow 就像HTML表格的标记。
TableLayout常用的属性 android:collapseColumns:隐藏指定的列 android:shrinkColumns:收缩指定的列以适合屏幕,不会挤出屏幕 android:stretchColumns:尽量把指定的列填充空白部分 android:layout_column:控件放在指定的列 android:layout_span:该控件所跨越的列数
源码
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TableRow> <Button android:text="Button11" /> <Button android:text="Button12" /> <Button android:text="Button13" /> </TableRow> <TableRow> <Button android:text="Button21" /> <Button android:layout_span="2" android:text="Button23" /> </TableRow> </TableLayout>显示效果: