TableLayout说明:
1:TableLyaout 提供了android:layout_span,可以使用此属性让一个单元格跨越多列 ,相当于 HTML 的 colspan属性
2:TableLayout的子控件不能指定android:layout_width="wrap_content",它们会被强制接受fill_parent
3.TableLayout的内容是使用行来定义的,而不是使用列,Android通过查找包含最多单元格的行来确定表格中的列数
测试:
java代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
layout文件:
<?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:collapseColumns="3,4,5"
android:stretchColumns="1,2"
android:shrinkColumns="0,6"
>
<TableRow >
<Button android:text="AA00"/>
<Button android:text="BB11"/>
<Button android:text="CC22"/>
<Button android:text="DD33"/>
<Button android:text="EE44"/>
<Button android:text="FF55"/>
<Button android:text="XXXXXXXXXXXXXXXXXX"/>
</TableRow>
<TableRow >
<Button android:text="AA00"/>
<Button android:text="BB11"/>
<Button android:text="CC22"/>
<Button android:text="XXXXXXXXXXXXXXXXXX"/>
</TableRow>
<TableRow >
<Button android:text="AA00"/>
<Button android:text="BB11" android:layout_span="2"/>
<Button android:text="CC22"/>
</TableRow>
<Button android:text="BUTTON"
android:layout_width="wrap_content"
android:gravity="center"/>
</TableLayout>
属性说明:
collapseColumns(隐藏)
设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
1.android:collapseColumns:以第0行为序,隐藏指定的列:把
android:collapseColumns=0,3 意思是把第0和第3列隐藏 ,即AA00,DD33隐藏
stretchColumns(拉伸)
设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)
的列的列索引,多列个用“,”隔开(多列 每列填充空隙大小一样)
当LayoutRow里面的控件已经布满布局时,shrinkColumns不起作用,设置了
stretchColumns="1,2",布局完全没有改变,因为LayoutRow里面已经没有 空间了。
shrinkColumns (收缩)
设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开
当LayoutRow里面的控件还没有布满布局时,shrinkColumns不起作用,设置了
shrinkColumns布局完全没有改变,因为LayoutRow里面还剩足够的
空间。当LayoutRow布满控件时,设置了shrinkColumns,则控件自动向垂直
方向填充空间
分享到:
相关推荐
TableLayout,实现动态添加和删除行,判断行中的数据是否含有空值,可以手动地输入数据,也可以选择数据添加在表格中,并实现统计表格中的数据。
android中利用tablelayout实现表格效果
TableLayout实现gridview嵌套gridview效果.md
安卓 tablelayout布局实例..欢迎下载学习
Android使用TableLayout动态布局实例: http://blog.csdn.net/lk_blog/article/details/7436380
android 利用TableLayout自动生成表格
TableLayout+ViewPager+Fragment原生高级控件开发的一个可滑动的标题栏索引
TableLayout 简单程序,但不常用的话容易忘记。特此发布,以备不时之需
利用TableLayout自定义可点击表格
用TableLayout实现九宫格参差不齐的排版用TableLayout实现九宫格参差不齐的排版
018集-TableLayout视频教程,讲解比较生动详细。
Android入门第四篇之TableLayout (一).docx
tablelayout, 基于表的Java UI工具箱布局 请使用 TableLayout讨论组的支持。概述TableLayout是一个轻量级的Java库,它使用逻辑 table 来设置UI小部件的位置和大小,类似于HTML表。 TableLayout的核心是 UI,它支持 ...
Android入门第五篇之TableLayout (二).docx
本源码是博客《解读 LWUIT 之九:使用布局管理器(Layout Manager)》中作者写的 Hello TableLayout 源代码。博客链接地址:http://blog.csdn.net/defonds/archive/2010/03/02/5338551.aspx。
Android移动应用开发表格布局TableLayout的常用属性.pdf 学习资料 复习资料 教学资源
andorid tablelayout实例 疯狂Android讲义
TableLayout的基本用法,选项卡
TableLayout 简单程序,但不常用的话容易忘记。特此发布,以备不时之需