TableLayout 表格布局管理器
2013-04-14 18:09
393 查看
与表格相似,以行和列的形式来管理放入其中的UI组件,在表格布局中,可以添加多个<TableRow>标记,每个<TableRow>标记占用一行。由于<TableRow>也是容器,所以还可以在此容器中添加其他组件,没添加一个组件,表格就会增加一列。列可以被隐藏,也可以被收缩或拉伸。
基本语法:
<TableLayout xmls:android="..."
属性列表
>
<TableRow 属性列表> 需要添加的UI组件</TableRow>
</TableLayout>
本身特有属性:
android:collapseColumns(设置需要隐藏的列的序列号,多个序列号用","分隔)
android:shrinkColumns(设置需要收缩的列的序列号,多个序列号用","分隔)
android:stretchColumns(设置需要拉伸的列的序列号,多个序列号用","分隔)
简单实例代码:
基本语法:
<TableLayout xmls:android="..."
属性列表
>
<TableRow 属性列表> 需要添加的UI组件</TableRow>
</TableLayout>
本身特有属性:
android:collapseColumns(设置需要隐藏的列的序列号,多个序列号用","分隔)
android:shrinkColumns(设置需要收缩的列的序列号,多个序列号用","分隔)
android:stretchColumns(设置需要拉伸的列的序列号,多个序列号用","分隔)
简单实例代码:
<?xml version="1.0" encoding="utf-8"?> <TableLayout android:id="@+id/tableLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/background_a" android:gravity="center_vertical" android:stretchColumns="0,3" > <!-- 第一行--> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView/> <TextView android:text="用户名" android:id="@+id/textView1" android:layout_width="wrap_content" android:textSize="24px" android:layout_height="wrap_content" /> <EditText android:id="@+id/editText1" android:textSize="24px" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="200px"/> <TextView /> </TableRow> <!-- 第二行--> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView/> <TextView android:text="密码" android:id="@+id/textView2" android:textSize="24px" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:textSize="24px" android:id="@+id/editText2" android:inputType="textPassword"/> <TextView /> </TableRow> <!-- 第三行--> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView/> <Button android:text="登录" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:text="取消? android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView /> </TableRow> </TableLayout>
相关文章推荐
- Android开发5:布局管理器2(表格布局TableLayout)
- Android开发5:布局管理器2(表格布局TableLayout)
- Android布局方式之表格布局管理器(TableLayout)
- TableLayout 表格布局管理器
- Android学习笔记13:表格布局管理器TableLayout
- Android学习笔记13:表格布局管理器TableLayout
- Android五布局——表格布局TableLayout
- TableLayout表格布局学习
- android:TableLayout表格布局详解
- (三)Android布局之表格布局(TableLayout)
- Android TableLayout 表格布局
- TableLayout 表格布局,FrameLaout 帧布局 ,AbsoluteLayout绝对布局的分析
- Android布局之TableLayout(表格布局)
- android布局 表格布局 (TableLayout)
- android:TableLayout表格布局
- 「喵神成长史」『布局篇』TableLayout(表格布局)
- Android UI之TableLayout(表格布局)
- android 底部表格布局TableLayout
- android五大布局之TableLayout(表格布局)
- 【Android开发学习24】界面布局之表格布局TableLayout+TableRow