Android布局_表格布局TableLayout
一、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的更多相关文章
- Android基础_2 Activity线性布局和表格布局
在activity的布局中,线性布局和表格布局是最简单的,这次分别从线性布局,表格布局以及线性布局和表格混合布局做了实验,实验中只需要编写 相应的xml的代码,java代码不需要更改,因为我们这里只是 ...
- WPF的布局-Grid(表格布局)
1. Grid布局就是表格布局 如下图: 2. 使用方法 2.1. 先生成适量的行和列,代码如下: <Grid><!--使用Grid控件--> <Grid.ColumnD ...
- Android:控件布局(表格布局)TableLayout
TableLayout继承LinearLayout 实例:用表格布局实现计算机布局>>>>>>>>>>>> 有多少个TableR ...
- .Net程序猿玩转Android开发---(8)表格布局TableLayout
表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...
- Android 自学之表格布局 TableLayout
表格布局(TableLayout),表格布局采用行.列的形式来管理UI组件,TableLayout并不需要明确的声明多少行,多少列,而是通过TableRow.其他组件来控制表格的行数和列数. 每次想T ...
- Android中的表格布局TableLayout
表格布局最基本的三个属性: XML代码实例: <?xml version="1.0" encoding="utf-8"?> <LinearLa ...
- Android——布局(线性布局linearLayout,表格布局TableLayout,帧布局FrameLayout)
线性布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:androi ...
- android——相对布局,表格布局
1.相对布局 RelativeLayout 又称作相对布局,也是一种非常常用的布局.和LinearLayout 的排列规则不同,RelativeLayout 显得更加随意一些,它可以通过相对定位的方式 ...
- Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局
1. 相对布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...
随机推荐
- javaWEB国际化(jsp中使用)
在jsp页面中使用国际化方法,首先将jstl开源架包:jstl.jar,standard.jar导进去 并在src目录下建立以test开头,.properties结尾的文件:test_en_US.pr ...
- 使用Window Live Writer写博客
1.打开“日志账户”—>“日志选项”. 2.点击“更新账户信息”. 3.输入博客地址,用户名和密码,点击“下一步”. 4.耐心等待片刻... 5.设置“日志昵称”,点击“完成”. 这样就大功告成 ...
- wpfのuri(让你完全明白wpf的图片加载方式以及URI写法)
绝对 pack WPF URI pack://application:,,,/是协议:“,,,”是“///”的变体 1.资源文件 — 本地程序集 Uri uri = new Uri("pac ...
- Android编译中m、mm、mmm的区别
准备工作 在AndroidSource Code中有envsetup.sh档案,当执行过此档案后,可以大幅将build的过程简单化.自动化 此档案在src(android source code 位置 ...
- ContentProvider官方教程(6)provider支持的数据类型
Provider Data Types Content providers can offer many different data types. The User Dictionary Provi ...
- easyui表单插件-包括日期时控件-列表
← jQuery EasyUI 表单插件 – Numberspinner 数值微调器 jQuery EasyUI 表单插件 - Timespinner 时间微调器 jQuery EasyUI 插件 ...
- 25-React事件处理及条件渲染
Handling Events React元素的事件处理非常类似于对DOM元素添加事件处理,但有一部分的语法不同: 1.React事件使用camelCase(驼峰命名法)来进行命名,而不是小写字母 2 ...
- Codeoforces 558 B. Duff in Love
// B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- 使用Hibernate框架,新增数据后如何返回新增数据的全部信息
一.需求描述:一个修改事物(TRANSACTION)先后包括子事物修改和子事物新增,修改事物完成后返回其子事物新增的全部数据 二.实现:若实现修改对象后还需要新增一个新对象,并返回新对象的需求,保存 ...
- Windows Live Writer代码高亮插件对比
一.Paste ASVisual Studio Code 参考:http://www.cnblogs.com/mikelij/archive/2010/11/13/1876199.html 插件下载: ...