TableLayout继承LinearLayout

有多少个TableRow对象就有多少行,

列数等于最多子控件的TableRow的列数

直接在TableLayout加控件,控件会占据一行

TableLayout属性(也叫全局属性):*代表所有列

android:shrinkColumns -------设置可收缩的列,(内容过多,则收缩,扩展到第二行,控件没布满TableLayout时不起作用)

android:stretchColumns ------设置可伸展的列,(有空白则填充)

列可以同时具备stretchColumns及shrinkColumns属性

android:collapseColumns ------设置要隐藏的列(索引列从0开始)

内部控件属性:

android:layout_column -------该单元格在第几列显示

android:layout_span -------该单元格占据列数,默认为1

伸展收缩实例:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <!-- 表格1-伸展 --> <TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:shrinkColumns="0,1,2" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我占据一行" /> <TableRow> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="000000000000000000000000" >
</Button> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="111111111111111111111111" >
</Button> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="222222222222222222222222" >
</Button>
</TableRow> <TableRow> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="000000000000000000000000" >
</Button> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="我占据2列" >
</Button>
</TableRow>
</TableLayout> <!-- 表格2-收缩 --> <TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFCD6B"
android:stretchColumns="0,1" > <TableRow> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="填充一" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="填充二" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通三" />
</TableRow>
</TableLayout> </LinearLayout>

Android TableLayout 表格布局的更多相关文章

  1. android:TableLayout表格布局详解

    http://blog.csdn.net/justoneroad/article/details/6835915 这篇博文包括的内容:1.TableLayout简介2.TableLayout行列数的确 ...

  2. Android零基础入门第29节:善用TableLayout表格布局,事半功倍

    原文:Android零基础入门第29节:善用TableLayout表格布局,事半功倍 前面学习了线性布局和相对布局,线性布局虽然方便,但如果遇到控件需要排列整齐的情况就很难达到要求,用相对布局又比较麻 ...

  3. 【转】TableLayout(表格布局)

    转自:http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864536.html TableLayout(表格布局) 表格布局模型以行列的形式管 ...

  4. Android课程---表格布局TableLayout

    特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...

  5. android的布局-----TableLayout(表格布局)

    学习导图 (1)TableLayout的相关简介 java的swing编程和html中经常会使用到表格,可见表格的应用开发中使用还是比较多的,同样android也为我们提供这样的布局方式. (2)如何 ...

  6. Android之TableLayout表格布局

    1.相关属性 1.1.常用属性 android:collapseColumns 设置需要被隐藏的列的序列号 android:shrinkColumns 设置允许被收缩的列的序列号 android:st ...

  7. Android布局-TableLayout表格布局

    一.表格布局-TableLayout 1.概念 表格布局采用行列的形式来管理UI的控件.表格布局适合于有规则的布局. TableRow,用来管理行,TableRow中的一个空间占据该行的一列.若不用T ...

  8. 案例:TableLayout表格布局——迷你计算器

    计算器可以常用线性布局(LinearLayout)和表格布局(tableLayout).Gridlayout 今天我用的是表格布局 效果如下: 代码如下: <TableLayout xmlns: ...

  9. TableLayout(表格布局)

    表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View的对象.TableRow可以添加子控件,每添加一个为一列. TableLayout属性: android ...

随机推荐

  1. hdu 2871 Memory Control(线段树)

    题目链接:hdu 2871 Memory Control 题目大意:模拟一个内存分配机制. Reset:重置,释放全部空间 New x:申请内存为x的空间,输出左地址 Free x:释放地址x所在的内 ...

  2. java中按字节获得字符串长度的两种方法 Java问题通用解决代码

    jdk本身就自带获取字符串字节长度的api了,但字符串如果包含特殊符号或全半角符号或标点符号获取到的结果会有偏差,最好的证据就是新浪微博的字数统计了 // jdk自带的获取字节长度 //注意getBy ...

  3. Python Windows文件操作

    获得目录和文件名 os.getenv()获取环境变量 os.putenv()设置环境变量 os.getcwd() 获得当前目录 os.chdir(‘要设置的当前目录’) os.listdir() 返回 ...

  4. AIX 安装标准

    文件夹 一.网卡需求 二.光纤卡需求 三.磁盘需求 四.主机文件系统需求 五.主机名命名规范 六.安装设置规范 七.參数改动规范 八.时钟同步设置 九.rootvg做镜像 十.AIX系统安全加固 一. ...

  5. mfs客户端挂载

    1.安装fuse yum install fuse fuse-devel 2.加载fuse模块 modprobe fuse 3.创建mfs用户 useradd mfs -s /sbin/nologin ...

  6. UserScan的处理流程分析

    UserScan的处理流程分析 前置说明 Userscan是通过client或cp中发起的scanner操作. 在Scan中通过caching属性来返回能够返回多少条数据.每次进行next时. 通过b ...

  7. View Controller容器

    在 iOS 5 之前,view controller 容器是 Apple 的特权.实际上,在 view controller 编程指南中还有一段申明,指出你不应该使用它们.Apple 对 view c ...

  8. JQ中find()与filter()的区别

    刚开始学的时候,对于find()和filter()有点理不清楚,下面通过案例相信就可以很快的区分清楚 以下是代码 find弹出的是 filter()弹出的是 下面我们添加div的class是rain ...

  9. sql exist 优化查询时间

    1.非exist,查询需要20多秒 2.使用exist后 3.表连接也能优化

  10. eclipse 导入maven 父子项目

    你先要确认svn上是否是maven项目,否则要自己重新建一个maven项目然后直接引入目录了.如果确认是maven项目,那么有个两个方案.案一:先用任何client软件将svn下载.然后在eclips ...