Android:控件布局(表格布局)TableLayout
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的更多相关文章
- 探究android控件及布局
控件(widget) 1. TextView(该控件的一些需要注意的属性,下同) gravity="center"textSize="24sp"textColo ...
- Android布局— — —表格布局
表格布局 以表格的形式来显示界面中的控件,表格的每一行为一个TableRow,每当一个控件添加到TableRow中,就生成一个单元格. 语法格式: <TableLayout xmlns:andr ...
- iOS 开发 ZFUI framework控件,使布局更简单
来自:http://www.jianshu.com/p/bcf86b170d9c 前言 为什么会写这个?因为在iOS开发中,界面的布局一直没有Android布局有那么多的方法和优势,我个人开发都是纯代 ...
- Qt基本控件及三大布局
Qt基本控件及三大布局 来源: http://blog.csdn.net/a2604539133/article/details/73920696 Qt基本模块 一.Qt的三大布局 QHBoxLayo ...
- c#学习笔记之使用 TableLayoutPanel 控件设置窗体布局
使用 TableLayoutPanel 控件设置窗体布局 在 Visual Studio IDE 左侧,找到“工具箱”选项卡. 选择“工具箱”选项卡,随即将显示工具箱.(或者,在菜单栏上,依次选择“视 ...
- Android控件属性大全(转)
http://blog.csdn.net/pku_android/article/details/7365685 LinearLayout 线性布局 子元素任意: Tab ...
- 第24讲 UI_布局 之帧布局 表格布局 绝对布局
第24讲 UI_布局 之帧布局 表格布局 绝对布局 3. FrameLayout(帧布局) 帧布局是从屏幕的左上角(0,0)坐标开始布局,多个组件层叠排序,后一个组件总会将前一个组件所覆盖,除非最后一 ...
- android控件的属性
android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...
- Android控件TextView的实现原理分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8636153 在前面一个系列的文章中,我们以窗口 ...
- Android控件介绍
1. 介绍 Android控件大多位于android.widget, android.view.View为他们的父类对于Dialog系列, android.app.Dialog为父类 Android的 ...
随机推荐
- GDI+ 中发生一般性错误。
GDI+ 中发生一般性错误. “/wechat”应用程序中的服务器错误. GDI+ 中发生一般性错误. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈跟踪信息,以了解有关该错误以及 ...
- JAVA坏境变量中的JAVA_HOME path classpath 的设置与作用。
在把jdk安装到计算机中之后,我们来进行设置使java环境能够使用. 首先右键点我的电脑.打开属性.然后选择“高级”里面的“环境变量”,在新的打开界面中的系统变量需要设置三个属性“JAVA_HOME” ...
- 脱离rails 使用Active Record
目录结构 database.yml development: adapter: sqlite3 database: db/test.db pool: 5 timeout: 5000 001_schem ...
- NPM使用
安装路径修改: 4.配置npm的全局模块存放路径和cache路径 输入以下命令 npm config set prefix “D:\Program Files\node\node-global” n ...
- Replace JSON.NET with ServiceStack.Text in ASP.NET Web API
Because ServiceStack.Text performs much better I recently stumbled across a comparison of JSON seria ...
- XXX项目 android 开发笔记
1 工具? eclipse or android studio fragment 套用
- [kuangbin带你飞]专题一 简单搜索
ID Origin Title 454 / 1008 Problem A POJ 1321 棋盘问题 328 / 854 Problem B POJ 2251 Dungeon Ma ...
- mssqlserver 批量插入示例
public bool DoQuestionSqlBulkCopy(DataTable dtDoQuestion, string DoQuestionName, ...
- SELinux配置不当导致httpd无法在非80端口启动
检测是否为selinux导致httpd启动失败,若setenforce 0以后就可以启动,就表示selinux配置不当. 首先本机要支持semanage命令,安装方法网上有. semanage po ...
- 图标的使用————JAVA——Swing
public class MyImageIcon extends JFrame{ public MyImageIcon() { JFrame jf=new JFrame(); ...