tablelayout与常见的表格类似, 以行, 列的形式管理放入其中的UI控件. 基本形式为:
<Tablelayout xmlns:android="http://schemas.android.com/apk/res/android"
属性列表
>
<TableRow 属性列表>需要添加的UI组件</TableRow>
<TableRow 属性列表>需要添加的UI组件</TableRow>
....
</TableLayout>
tablelayout 除了支持LinearLayout的全部XML属性外, 还支持一些特有的属性:
android:collapseColumns 设置需要被隐藏的列的列序号(序号从0开始), 多个列序号之间用","分隔
android:shrinkColumns 设置允许被收缩的列的列序号(序号从0开始),多个列序号之间用","分隔
android:stretchColumns 设置允许被拉伸的列的列序号(序号从0开始), 多个列序号之间用","分隔
TableLayout 默认是没有边框的, 如果想做出边框的效果, 可以在行之间添加:
<View
android:layout_height="3dip"
android:background="#000000"
/>
同样的,在两个水平排列的TableLayout之间也加上述的View, 可以达到垂直分隔线的效果.