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:TableLayout表格布局详解
http://blog.csdn.net/justoneroad/article/details/6835915 这篇博文包括的内容:1.TableLayout简介2.TableLayout行列数的确 ...
- Android零基础入门第29节:善用TableLayout表格布局,事半功倍
原文:Android零基础入门第29节:善用TableLayout表格布局,事半功倍 前面学习了线性布局和相对布局,线性布局虽然方便,但如果遇到控件需要排列整齐的情况就很难达到要求,用相对布局又比较麻 ...
- 【转】TableLayout(表格布局)
转自:http://www.cnblogs.com/zhangs1986/archive/2013/01/17/2864536.html TableLayout(表格布局) 表格布局模型以行列的形式管 ...
- Android课程---表格布局TableLayout
特别注意:由于表格布局继承自线性布局,因此并不显示表格线 示例代码: <?xml version="1.0" encoding="utf-8"?> ...
- android的布局-----TableLayout(表格布局)
学习导图 (1)TableLayout的相关简介 java的swing编程和html中经常会使用到表格,可见表格的应用开发中使用还是比较多的,同样android也为我们提供这样的布局方式. (2)如何 ...
- Android之TableLayout表格布局
1.相关属性 1.1.常用属性 android:collapseColumns 设置需要被隐藏的列的序列号 android:shrinkColumns 设置允许被收缩的列的序列号 android:st ...
- Android布局-TableLayout表格布局
一.表格布局-TableLayout 1.概念 表格布局采用行列的形式来管理UI的控件.表格布局适合于有规则的布局. TableRow,用来管理行,TableRow中的一个空间占据该行的一列.若不用T ...
- 案例:TableLayout表格布局——迷你计算器
计算器可以常用线性布局(LinearLayout)和表格布局(tableLayout).Gridlayout 今天我用的是表格布局 效果如下: 代码如下: <TableLayout xmlns: ...
- TableLayout(表格布局)
表格布局模型以行列的形式管理子控件,每一行为一个TableRow的对象,当然也可以是一个View的对象.TableRow可以添加子控件,每添加一个为一列. TableLayout属性: android ...
随机推荐
- 聚类分析算法及SAS实现
聚类分析是用户细分里面最为重要的工具,而用户细分则是整个精准营销里面的基础. 聚类分析方法分为: 层次法:可分为凝聚式和分列式,适用于观测数比较少的情形 1.凝聚式:将每个观测都归为一类,然后每次都将 ...
- ar命令提取.o的时候报错:is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
在解压.a文件的时候,报错:s a fat file (use libtool(1) or lipo(1) and ar(1) on it),原因是该.a文件包含了多个cpu架构,比如armv7,ar ...
- 项目开发中的一些注意事项以及技巧总结 基于Repository模式设计项目架构—你可以参考的项目架构设计 Asp.Net Core中使用RSA加密 EF Core中的多对多映射如何实现? asp.net core下的如何给网站做安全设置 获取服务端https证书 Js异常捕获
项目开发中的一些注意事项以及技巧总结 1.jquery采用ajax向后端请求时,MVC框架并不能返回View的数据,也就是一般我们使用View().PartialView()等,只能返回json以 ...
- 了解.net mvc实现原理ActionResult/View
了解.net mvc实现原理ActionResult/View 上一篇了解了请求至Controller的Action过程,这篇继续看源码处理Action收到请求数据再返回ActionResult到Vi ...
- 解决Windows平台通过cURL上传APP到蒲公英pgyer平台时无法使用中文升级描述的问题
解决Windows平台通过cURL上传APP到蒲公英pgyer平台时无法使用中文升级描述的问题 官方上传命令 curl -F file=@"315.apk" -F uKey=XXX ...
- Cannot open channel to 3 at election address :3888 java.net.ConnectException: Connection refused (Connection refused)
关于Linux中搭建分布式时可能遇到的问题 这个问题来自于今天安装zookeeper时踩的一个大坑,害的我花了一天时间.在搭建zookeeper的分布式时,往往要进行这样的配置: server.1=h ...
- 题外话:计算密集型 vs IO密集型
我们把任务分为计算密集型和IO密集型,erlang作为IO密集型的语言,适合网关等相关的场景,而对计算达到某一量级后,可能处理效率下降的很明显. erlang不适合数值计算.erlang是解释型的,虽 ...
- Android BroadcastReceiver介绍 (转)
原文地址:http://www.cnblogs.com/trinea/archive/2012/11/09/2763182.html 本文主要介绍BroadcastReceiver的概念.使用.生命周 ...
- unity绝对路径与相对路径转化
绝对路径->相对路径 string mp =“H:\unity(project)\New Unity Project\Assets\111.mat”; mp = mp.Substring(mp. ...
- Mysql字符串截取函数
今天建视图时,用到了MySQL中的字符串截取,很是方便. 感觉上MySQL的字符串函数截取字符,比用程序截取(如PHP或JAVA)来得强大,所以在这里做一个记录,希望对大家有用. 函数: 1.从左开始 ...