【Android布局之【TableLayout(表格布局)】
来源:互联网 发布:熊猫tv抢福袋软件 编辑:程序博客网 时间:2024/06/02 23:04
从字面上来看,TableLayout也比较简单,关键是要对相关的属性要熟悉,先看一个简单的例子(后面为效果图):
布局讲解:
接着我们再看看android官方文档中给出的例子:
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0,1,2" android:shrinkColumns="1,2" > <TextView android:text="Table Test" android:gravity="center"/> <TableRow> <TextView android:layout_column="1" android:text="姓名" android:gravity="center"/> <TextView android:text="基本信息" android:gravity="center"/> </TableRow> <TableRow> <TextView android:text=" 1 " android:gravity="center"/> <TextView android:text="hoyah" android:gravity="left"/> <TextView android:text="Wuhan University" android:gravity="right"/> </TableRow> <TableRow> <TextView android:text=" 2 " android:gravity="center"/> <TextView android:text="Google" android:gravity="left"/> <TextView android:text="hello Google" android:gravity="right"/> </TableRow> <TableRow> <TextView android:text="3" android:gravity="center"/> <TextView android:text="Android" android:gravity="left"/> <TextView android:text="Android OS" android:gravity="right"/> </TableRow></TableLayout>
布局讲解:
android:collapse="1隐藏该TableLayout里的TableRow的列1,即第2列(从0开始计算),若有多列要隐藏,用“,”隔开。
android:stretchColumns="0,1,2"设置列0、1、2为可伸展列。
android:shrinkColumns="1,2"设置列1、2为可收缩列。
android:background="@drawable/picture_name"本例中没有涉及此属性,它是要设置当前view 的背景图片,图片文件应该放在res文件夹下。
接着我们再看看android官方文档中给出的例子:
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1"> <TableRow> <TextView android:layout_column="1" android:text="Open..." android:padding="3dip" /> <TextView android:text="Ctrl-O" android:gravity="right" android:padding="3dip" /> </TableRow> <TableRow> <TextView android:layout_column="1" android:text="Save..." android:padding="3dip" /> <TextView android:text="Ctrl-S" android:gravity="right" android:padding="3dip" /> </TableRow> <TableRow> <TextView android:layout_column="1" android:text="Save As..." android:padding="3dip" /> <TextView android:text="Ctrl-Shift-S" android:gravity="right" android:padding="3dip" /> </TableRow> <View android:layout_height="2dip" android:background="#FF909090" /> <TableRow> <TextView android:text="X" android:padding="3dip" /> <TextView android:text="Import..." android:padding="3dip" /> </TableRow> <TableRow> <TextView android:text="X" android:padding="3dip" /> <TextView android:text="Export..." android:padding="3dip" /> <TextView android:text="Ctrl-E" android:gravity="right" android:padding="3dip" /> </TableRow> <View android:layout_height="2dip" android:background="#FF909090" /> <TableRow> <TextView android:layout_column="1" android:text="Quit" android:padding="3dip" /> </TableRow></TableLayout>效果图如下,大家可以上机调试一下:
- Android布局之TableLayout(表格布局)
- Android布局之TableLayout(表格布局)
- 【Android布局之【TableLayout(表格布局)】
- Android UI之TableLayout(表格布局)
- 【Android】界面布局之TableLayout(表格布局)
- Android TableLayout(表格布局)
- (转)【Android】界面布局之TableLayout(表格布局)
- (三)Android布局之表格布局(TableLayout)
- Android学习(十五)五布局之表格布局TableLayout
- Android:控件布局(表格布局)TableLayout
- android-TableLayout 表格布局
- Android 表格布局<TableLayout>
- android:TableLayout表格布局
- android:TableLayout表格布局
- Android TableLayout表格布局
- Android TableLayout 表格布局
- 2.Android笔记之TableLayout(表格布局)
- 12、从头学Android之布局之TableLayout表格布局
- 高性能建站指南URL
- 2010暴强淫才语录。。。
- 装载问题之二
- 条码/RFID标签打印方案
- 使用谷歌浏览器简单的调试网页和脚本
- 【Android布局之【TableLayout(表格布局)】
- 函数对比
- MS-SQL 如何处理嵌套事务
- 谈谈对程序员的培养
- 单片机
- 码流/码率/码速 解释
- 《老婆,你别挂我电话,我错了,接我电话,好吗?》一个真实故事的惨痛教训,希望女人们可以看完,珍惜爱你的那个人
- Oracle中如何计算时间差
- innerHTML在IE下的特殊:不支持table作为容器