一、TableLayout概述

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

二、TableLayout的全局属性

   1、android:collapseColumns = "1,2"

      隐藏从0开始索引列,列直接必须ongoing逗号隔开:1,2,5

<TableLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:collapseColumns="0" > <TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第一个按钮"
android:id="@+id/button" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第二个按钮"
android:id="@+id/button2" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第三个按钮"
android:id="@+id/button3" />
</TableRow>
</TableLayout>

  2、android:shrikColumns = "1,2"

      收缩从0开始的索引列。当可收缩的列太宽(内容过多)不会被挤出屏幕,列直接必须用逗号隔开:1,2,5,你可以通过"*"代替收缩所有列。注意一列能同时表示收缩和拉伸。

<TableLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="2" > <TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第一个按钮"
android:id="@+id/button" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第二个按钮"
android:id="@+id/button2" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第三个按钮大神快放假了凯撒的解放路卡手机的路口发生的积分卡拉斯加"
android:id="@+id/button3" />
</TableRow>
</TableLayout>

  3、android:stretchColumns = "1,2"

    拉伸从0开始的索引列。以填满剩下的多余空白控件,列直接必须用逗号隔开:1,2,3,可以通过"*"代替收缩所有列。注意一列能同时表示收缩和拉伸。

<TableLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="2" > <TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第一个按钮"
android:id="@+id/button" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第二个按钮"
android:id="@+id/button2" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第三个按钮"
android:id="@+id/button3" />
</TableRow>
</TableLayout>

三、TableLayout的局部属性(内部控件所有属性)

  1、android:layout_column = "1"       该控件显示在第二列

   2、android:layout_span = "2"           该控件占据2列

四、实现简单的计算器布局

<TableLayout    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:shrinkColumns="*"> <TextView
android:gravity="right|center"
android:layout_width="fill_parent"
android:layout_height="40"
android:text="90"
android:id="@+id/textView" /> <TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="@+id/button" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/button2" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="@+id/button3" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:id="@+id/button4" />
</TableRow> <TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="@+id/button5" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="@+id/button6" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="@+id/button7" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:id="@+id/button8" />
</TableRow>
</TableLayout>

  

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

  1. Android基础_2 Activity线性布局和表格布局

    在activity的布局中,线性布局和表格布局是最简单的,这次分别从线性布局,表格布局以及线性布局和表格混合布局做了实验,实验中只需要编写 相应的xml的代码,java代码不需要更改,因为我们这里只是 ...

  2. WPF的布局-Grid(表格布局)

    1. Grid布局就是表格布局 如下图: 2. 使用方法 2.1. 先生成适量的行和列,代码如下: <Grid><!--使用Grid控件--> <Grid.ColumnD ...

  3. Android:控件布局(表格布局)TableLayout

    TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...

  4. .Net程序猿玩转Android开发---(8)表格布局TableLayout

    表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...

  5. Android 自学之表格布局 TableLayout

    表格布局(TableLayout),表格布局采用行.列的形式来管理UI组件,TableLayout并不需要明确的声明多少行,多少列,而是通过TableRow.其他组件来控制表格的行数和列数. 每次想T ...

  6. Android中的表格布局TableLayout

    表格布局最基本的三个属性: XML代码实例: <?xml version="1.0" encoding="utf-8"?> <LinearLa ...

  7. Android——布局(线性布局linearLayout,表格布局TableLayout,帧布局FrameLayout)

    线性布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:androi ...

  8. android——相对布局,表格布局

    1.相对布局 RelativeLayout 又称作相对布局,也是一种非常常用的布局.和LinearLayout 的排列规则不同,RelativeLayout 显得更加随意一些,它可以通过相对定位的方式 ...

  9. Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局

    1. 相对布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...

随机推荐

  1. 利用Selenium自动化web测试

    简介: Selenium 是一个没有正式指导手册的开源项目,这让测试人员的问题调查很费时间.本文为基于 Selenium 1.0(发布于 2009 年 6 月)的测试期间的常见问题提供最佳实践. 简介 ...

  2. css select 样式列表-----另一种样式列表

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org ...

  3. 关于easyui的窗口和tab页面不执行js说明

    一直以来群里里面很多人反应,在用tab加载界面的时候,界面里面的js不会执行.今天GodSon在此说明一下原因. 不管是window,dailog还是tab其实质最终都是继承了panel.panel有 ...

  4. github for windows回滚到某一个版本,

    建议先学会使用git命令再学GUI版的git,git本来就是命令行程序,GUI本质就是执行一些命令.仅从一些icon和单词去理解一些操作难免会有偏差.而反过来,熟悉命令会更好地理解GUI操作.想要回滚 ...

  5. 北邀 E Elegant String

    E. Elegant String Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB   64-bit integer ...

  6. Mybatis like 模糊查询问题

    1.mysql:LIKE CONCAT('%',#{empname},'%' ) 或者 LIKE CONCAT('%',‘${empname}’,'%' ) 2.oracle:LIKE '%'||#{ ...

  7. linux Centos 6.5 FTP服务原理及vsfptd的安装、配置(转)

    本篇随笔将讲解FTP服务的原理以及vsfptd这个最常用的FTP服务程序的安装与配置... 一.FTP服务原理 FTP(File Transfer Protocol)是一个非常古老并且应用十分广泛的文 ...

  8. android 入门 002 (拨打电话,发送短信)

    一.拨打电话 1.首先做好界面,代码如下: layout =>activity_main.xml 中 <LinearLayout xmlns:android="http://sc ...

  9. 关于C指针

    地址概念:内存基本单元是一个字节,一个字节8个位.在定义变量的时候,如int a=10:系统为变量a分配2个字节空间:1000~1001,并在1001~1002中存有数据10.内存中没有变量a,只有1 ...

  10. FZU 2168 防守阵地 I

    Problem Description 部队中共有N个士兵,每个士兵有各自的能力指数Xi,在一次演练中,指挥部确定了M个需要防守的地点,按重要程度从低到高排序,依次以数字1到M标注每个地点的重要程度, ...