TableLayout学习总结!
来源:互联网 发布:预科生的贩毒网络免费 编辑:程序博客网 时间:2024/06/11 13:48
TableLayout,顾名思义,代表表格布局。类似HTML编程中的<table>。在某些布局时较优越。
本人不经常使用,在登录表单页面的编写时,偶尔会涉及到。
TableLayout的优越性之一就是可以在TableLayout属性下控制拉伸,而<TableRow>则表示一行。比如:
效果如图:
效果如图:
效果如图:
效果如图:
让页面显示更多view,如图示:
本人不经常使用,在登录表单页面的编写时,偶尔会涉及到。
因为用的不多,所以不熟。今天挑出来专门研究下。
在xml中,一般都是这种结构进行使用:
<TableLayout> <TableRow> <view /> </TableRow> </TableLayout>
TableLayout的优越性之一就是可以在TableLayout属性下控制拉伸,而<TableRow>则表示一行。比如:
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="2" > <TableRow> <Button android:hint="helloworld"/> <Button android:hint="helloworld"/> <Button android:hint="helloworld"/> </TableRow> </TableLayout>
效果如图:
也可以改成android:stretchColumns="0,2",这时候代表第一列和第三列拉伸。
在LinearLayout下有layout_weight属性来进行拉伸控制,在这里,也可以不使用stretchColumns,使用weight控制。比如:
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TableRow> <Button android:hint="helloworld" android:layout_weight="1"/> <Button android:hint="helloworld"/> <Button android:hint="helloworld" android:layout_weight="1"/> </TableRow> </TableLayout>
效果如图:
和第二个例子一模一样,只是代码的书写量变多了,也体现了程序员的技术水平。
collapseColumns的属性使用:
编写如下代码:
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1,2" android:collapseColumns="1" > <TableRow> <Button android:hint="helloworld0"/> <Button android:hint="helloworld1"/> <Button android:hint="helloworld2"/> <Button android:hint="helloworld3"/> </TableRow> </TableLayout>
效果如图:
collapseColumns表示第几列缩进。
android:shrinkColumns的使用:
编写如下代码:
<TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="1,2" android:collapseColumns="1" > <TableRow> <Button android:hint="helloworld0222222222222222222222222222222"/> <Button android:hint="helloworld1333333333333333333333333333333"/> <Button android:hint="helloworld2444444444444444444444444444444"/> <Button android:hint="helloworld3444444444444444444444444444444"/> </TableRow> </TableLayout>
效果如图:
可以看到有些button已经被挤出来了。
这时候使用shrinkColumns属性:
<pre name="code" class="html"><TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:shrinkColumns="0,1,2,3" > <TableRow> <Button android:hint="helloworld0222222222222222222222222222222"/> <Button android:hint="helloworld1333333333333333333333333333333"/> <Button android:hint="helloworld2444444444444444444444444444444"/> <Button android:hint="helloworld3444444444444444444444444444444"/> </TableRow> </TableLayout>
让页面显示更多view,如图示:
掌握这么多,我猜基本上TableLayout就差不多可以了吧。
0 0
- TableLayout学习总结!
- TableLayout总结
- Android UI学习 - TableLayout
- Android TableLayout学习
- Android UI学习 - TableLayout
- Android UI学习 - TableLayout
- Android UI学习 - TableLayout
- Android UI学习 - TableLayout
- TableLayout表格布局学习
- Android UI学习 - TableLayout
- Android学习:TableLayout使用
- Android TableLayout布局学习
- Android UI学习 - TableLayout
- android学习笔记9:TableLayout
- Android UI学习 – TableLayout
- Android布局方式(TableLayout)学习
- Android 学习笔记(5) --tablelayout
- Android学习笔记TableLayout布局
- android 中 dumpsys 命令使用
- html的file 控件
- linux 设置网络API --- 开/关网卡、设置/获取Mac地址
- yum的使用
- MFC:HOOK编程
- TableLayout学习总结!
- 使用static关键字
- halcon学习笔记——(14)算子_开发
- STM32103VE HardFault 故障问题
- 递归方法求解n!
- 达内助我圆梦UI设计师 万元月薪入职新锐互动
- Interface Builder设置圆角效果
- Android开发:LayoutParams的用法
- 签名解密,内容验证