表格布局

以表格的形式来显示界面中的控件,表格的每一行为一个TableRow,每当一个控件添加到TableRow中,就生成一个单元格。

语法格式:

<TableLayout

  xmlns:android="http://schemas.android.com/apk/res/android"

  xmls:tools=""http://schemas.android.com/tools

  android:id="@+id/ "

  android:layout_width=" "

  android:layout_height=" "

  android:shrinkColumns=" "

  android:stretchColumns=" "

  android:collapseColumns=" ">

  <TableRow

    android:id="@+id/ "

    android:layout_width=" "

    android:layout_height=" ">

    <Widgets>

      ...

    </Widgets>

  </TableRow>

</TableLayout>

特有属性:

shrinkColumns           指定该列被收缩,列号从0开始

stretchColumns          指定该列被延伸,列号从0开始

collapseColumns         指定该列被隐藏,列号从0开始

例子:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:shrinkColumns="0"
android:stretchColumns="1"
android:collapseColumns="2"> <TableRow
android:id="@+id/tablerow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> <Button
android:id="@+id/btn1"
android:layout_height="wrap_content"
android:text="Button1"/> <Button
android:id="@+id/btn2"
android:layout_height="wrap_content"
android:text="Button2"/> <Button
android:id="@+id/btn3"
android:layout_height="wrap_content"
android:text="Button3"/>
</TableRow> <TableRow
android:id="@+id/tablerow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> <Button
android:id="@+id/btn4"
android:layout_height="wrap_content"
android:text="Button4"/> <Button
android:id="@+id/btn5"
android:layout_height="wrap_content"
android:text="Button5"/> <Button
android:id="@+id/btn6"
android:layout_height="wrap_content"
android:text="Button6"/>
</TableRow> </TableLayout>

注意:<TableRow>中的控件不能指定layout_width

												

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

  1. 第24讲 UI_布局 之帧布局 表格布局 绝对布局

    第24讲 UI_布局 之帧布局 表格布局 绝对布局 3. FrameLayout(帧布局) 帧布局是从屏幕的左上角(0,0)坐标开始布局,多个组件层叠排序,后一个组件总会将前一个组件所覆盖,除非最后一 ...

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

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

  3. android 关于表格布局的认识

    表格布局(TableLayout) 使用的知识点有: 控件 TableRow:为这个表格添加一行 table的特殊属性 android:layout_column:确定此表格的列数 android:s ...

  4. Android笔记(十) Android中的布局——表格布局

    TableLayout运行我们使用表格的方式来排列控件,它的本质依然是线性布局.表格布局采用行.列的形式来管理控件,TableLayout并不需要明确的声明包含多少行多少列,而是通过添加TableRo ...

  5. android:TableLayout表格布局详解

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

  6. Android TableLayout 表格布局

    TableLayout继承LinearLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 Table ...

  7. Android first---常见布局

    ###绝对布局AbsoluteLayout    * android:layout_x="120dp"   在水平方向上偏移120像素     * android:layout_y ...

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

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

  9. [置顶] Android系统五大布局详解Layout

    我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前,视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit等 ...

随机推荐

  1. OA系统部门结构树

    public class DepartmentUtils { /** * @param topList 顶级部门列表 * @param removeId 删除部门的id * @return */ pu ...

  2. 华为面试题——约瑟夫问题的C++简单实现(循环链表)

    /*     author:jiangxin     Blog:http://blog.csdn.net/jiangxinnju     Function:method of Josephus que ...

  3. 【bzoj1019】汉诺塔

    [bzoj1019]汉诺塔 题意 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1019 分析 思路1:待定系数+解方程 设\(f[n]\)为 ...

  4. php向数据库写数据逻辑

    先写php 文件 1.post请求 1)先确定传进来的数据有值 没有就退出程序 if(!isset($_POST['username'])){ die('没有传值') } 2)设config.php ...

  5. 纯css3代码写无缝滚动效果

    主要用到css3中的动画 @keyframes, animation. 布局是外层一个div宽固定,然后overflow hidden 绝对定位,里面的ul 固定定位.通过对ul添加动画来实现效果.具 ...

  6. Scrum项目3.0

    1. 确保product backlog井然有序.(参考示例图1) 2. Sprint周期,一个冲刺周期,长度定为两周,本学期还有三个冲刺周期. 3. 确定Sprint目标. 3.1 产品负责人概括产 ...

  7. nyoj-----42一笔画问题

    一笔画问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 zyc从小就比较喜欢玩一些小游戏,其中就包括画一笔画,他想请你帮他写一个程序,判断一个图是否能够用一笔画下 ...

  8. 172. Factorial Trailing Zeroes -- 求n的阶乘末尾有几个0

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  9. OC self和super

    在OC中 1 self是一个指针,在每一个方法中都有一个self指针 2 self可以出现在所有的方法中(对象方法和类方法),不能在函数中 3 self指向调用者.(谁调用它就指向谁) 4 可以使用s ...

  10. 经验分享:使用 Restyle.js 简化 CSS 预处理

    Andrea Giammarchi的restyle.js是一个新的,基于JavaScript的CSS预处理器,能够运行在服务端(通过Node.js)或者浏览器中.它宣称自己是“一种简化的CSS方法”, ...