Android布局之TableLayout(表格布局)
来源:互联网 发布:dosbox mac 挂载 编辑:程序博客网 时间:2024/04/28 21:44
转载自:http://apps.hi.baidu.com/share/detail/33176011
从字面上来看,TableLayout也比较简单,关键是要对相关的属性要熟悉,先看一个简单的例子(后面为效果图):
<?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>
效果图如下,大家可以上机调试一下:
来自: http://hi.baidu.com/hoyah/blog/item/d9db34275d6f361a8b82a171.html
- 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表格布局
- 睡不着,总结一下!!!
- org.jboss.deployers.spi.DeploymentException
- DBA_1
- 母版页调用内容页的方法的简单实现
- 用Linux守护进程检测某个程序是否运行
- Android布局之TableLayout(表格布局)
- 单播、广播、组播(多播)
- 10 CSS3 and jQuery Loading Animations Solutions
- JSON入门
- WebApplicationContext 文章
- sleep 跟 wait有什么区别?
- 学习android JNI的那些事儿--------4. Field & Method --> Accessing Field
- 从爱到爱的距离--父亲 墨尘缘
- C语言和设计模式(总结篇)