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控件及布局

    控件(widget) 1. TextView(该控件的一些需要注意的属性,下同) gravity="center"textSize="24sp"textColo ...

  2. Android布局— — —表格布局

    表格布局 以表格的形式来显示界面中的控件,表格的每一行为一个TableRow,每当一个控件添加到TableRow中,就生成一个单元格. 语法格式: <TableLayout xmlns:andr ...

  3. iOS 开发 ZFUI framework控件,使布局更简单

    来自:http://www.jianshu.com/p/bcf86b170d9c 前言 为什么会写这个?因为在iOS开发中,界面的布局一直没有Android布局有那么多的方法和优势,我个人开发都是纯代 ...

  4. Qt基本控件及三大布局

    Qt基本控件及三大布局 来源: http://blog.csdn.net/a2604539133/article/details/73920696 Qt基本模块 一.Qt的三大布局 QHBoxLayo ...

  5. c#学习笔记之使用 TableLayoutPanel 控件设置窗体布局

    使用 TableLayoutPanel 控件设置窗体布局 在 Visual Studio IDE 左侧,找到“工具箱”选项卡. 选择“工具箱”选项卡,随即将显示工具箱.(或者,在菜单栏上,依次选择“视 ...

  6. Android控件属性大全(转)

    http://blog.csdn.net/pku_android/article/details/7365685 LinearLayout         线性布局        子元素任意: Tab ...

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

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

  8. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  9. Android控件TextView的实现原理分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8636153 在前面一个系列的文章中,我们以窗口 ...

  10. Android控件介绍

    1. 介绍 Android控件大多位于android.widget, android.view.View为他们的父类对于Dialog系列, android.app.Dialog为父类 Android的 ...

随机推荐

  1. 键盘--android 隐藏系统键盘

    . -----------------------------------------已验证----------------------------------- public static void ...

  2. KEIL编译错误总结:

    1 expected an identifier:#define宏定义常量后,如果再用前面定义的常量作为枚举常量就会报错,方法,去掉#define宏定义

  3. JAVA 单选按钮、复选按钮

    //单选按钮和复选按钮 import java.awt.*; import javax.swing.*; public class Jiemian6 extends JFrame{ JPanel mb ...

  4. Struts2返回JSON对象的方法总结

    如果是作为客户端的HTTP+JSON接口工程,没有JSP等view视图的情况下,使用Jersery框架开发绝对是第一选择.而在基于Spring3 MVC的架构下,对HTTP+JSON的返回类型也有很好 ...

  5. KS-检验(Kolmogorov-Smirnov test) -- 检验数据是否符合某种分布

    Kolmogorov-Smirnov是比较一个频率分布f(x)与理论分布g(x)或者两个观测值分布的检验方法.其原假设H0:两个数据分布一致或者数据符合理论分布.D=max| f(x)- g(x)|, ...

  6. 强大的JS数组

    1.数组的创建 var arrayObj = new Array(); //创建一个数组 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限, ...

  7. ruby的optparse使用小记

    #自定义转换器 1 opts.accept(Hash) do |string| hash = {} string.split(',').each do |pair| key,value = pair. ...

  8. XML通過XSD產生CLASS

    步驟一:通過XML獲取XSD 格式:xsd "XML的完整路徑帶文件名" /O:"輸出路徑不帶文件名". C:\Windows\system32>xsd ...

  9. Liferay中actionURL能够执行后台方法 ,但是页面不跳转问题解决方案

    在学习liferay的过程中,遇到了这么一个问题,actionURL能够执行后台方法 ,但是页面不跳转,以下是两种解决方案: 方案1(不推荐此种办法): 强制将页面重定向. 在actionURL执行的 ...

  10. mysql 错误1054

    问题,当查询数据时,输入字符串是数字时,可以查询,但当输入字母字符串时却不能查询,总是提示错误1054 解决:将字符串打上单引号 字段对应的值如果为字符或字符串类型的时候,应用英文单引号括起来,你用的 ...