Android开发5:布局管理器2(表格布局TableLayout)
版本:Android4.3 API18 学习整理:liuxinming
概念
单元格设置的三种行为方式
| XML属性 | 相关方法 | 说明 |
| android:collapseColumns | setColumnCollapsed(int,boolean) | 设置需要被隐藏的列的序列号。多个用逗号隔开 |
| android:shrinkColumns | setShrinkAllColumns(boolena) | 设置允许被收缩的列的序列号 |
| android:stretchColumns | setStretchAllColumns(boolena) | 设置允许被拉伸的列的序列号 |
下面看UI布局XML代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> <!-- 定义第一个表格布局,指定第2列允许收缩,第3列允许拉伸 -->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="2"
>
<!-- 直接添加按钮,它自己会占一行 -->
<Button android:id="@+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="占一行的按钮"
/>
<!-- 添加一行表格 begin -->
<TableRow >
<!-- 为该行添加三个按钮 begin -->
<Button android:id="@+id/button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通按钮"
/>
<Button android:id="@+id/button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="收缩的按钮,收缩的按钮,收缩的按钮"
/>
<Button android:id="@+id/button04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拉伸的按钮"
/>
<!-- 为该行添加三个按钮 end -->
</TableRow>
<!-- 添加一行表格 end --> </TableLayout>
<!-- 定义第二个表格布局,指定第2列被隐藏 -->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:collapseColumns="1"
>
<!-- 占一行的按钮 -->
<Button android:id="@+id/button011"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="占一行的按钮"
/>
<!-- 添加一行表格并添加三个按钮 begin -->
<TableRow >
<!-- 为该行添加三个按钮 begin -->
<Button android:id="@+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通按钮"
/>
<Button android:id="@+id/button13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我是被隐藏掉的按钮"
/>
<Button android:id="@+id/button14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通按钮"
/>
<!-- 为该行添加三个按钮 end -->
</TableRow>
<!-- 添加一行表格并添加三个按钮 end -->
</TableLayout>
<!-- 定义第三个表格布局,指定第2列和第3列可以被拉伸 -->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
>
<!-- 占一行的按钮 -->
<Button android:id="@+id/button05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="占一行的按钮"
/>
<!-- 添加一行表格并添加三个按钮 begin -->
<TableRow >
<!-- 为该行添加三个按钮 begin -->
<Button android:id="@+id/button06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通按钮"
/>
<Button android:id="@+id/button07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拉伸的按钮"
/>
<Button android:id="@+id/button08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拉伸的按钮"
/>
<!-- 为该行添加三个按钮 end -->
</TableRow>
<!-- 添加一行表格并添加三个按钮 end -->
<!-- 再次添加一个表格并添加两个按钮 begin -->
<TableRow >
<Button android:id="@+id/button09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通的按钮"
/>
<Button android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拉伸的按钮"
/>
</TableRow>
<!-- 再次添加一个表格并添加两个按钮 end -->
</TableLayout> </LinearLayout>
讲解:
调试效果图:
Android开发5:布局管理器2(表格布局TableLayout)的更多相关文章
- Android布局管理器(表格布局)
表格布局有TableLayout所代表,TableLayout继承了LinearLayout,因此他的本质依然是LinearLayout. 表格布局采用行.列的形式来进行管理,在使用的时候不需要声明多 ...
- 【Android 应用开发】AndroidUI设计之 布局管理器 - 详细解析布局实现
写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...
- [置顶] Android布局管理器 - 详细解析布局实现
布局管理器都是以ViewGroup为基类派生出来的; 使用布局管理器可以适配不同手机屏幕的分辨率,尺寸大小; 布局管理器之间的继承关系 : 在上面的UML图中可以看出, 绝对布局 帧布局 网格布局 相 ...
- AndroidUI设计之 布局管理器 - 详细解析布局实现
写完博客的总结 : 以前没有弄清楚的概念清晰化 父容器与本容器属性 : android_layout...属性是本容器的属性, 定义在这个布局管理器的LayoutParams内部类中, 每个布局管理器 ...
- android开发4:Android布局管理器1(线性布局,相对布局RelativeLayout-案例)
控件类概述 View 可视化控件的基类 属性名称 对应方法 描述 android:background setBackgroundResource(int) 设置背景 android:clickabl ...
- Android布局管理器(线性布局)
线性布局有LinearLayout类来代表,Android的线性布局和Swing的Box有点相似(他们都会将容器里面的组件一个接一个的排列起来),LinearLayout中,使用android:ori ...
- Android布局管理器(贞布局)
贞布局有FrameLayout所代表,它直接继承了ViewGroup组建 贞布局为每个加入其中的组件创建一个空白区域(一帧),所以每个子组件占用一帧,这些贞都会根据gravity属性执行自动对齐 贞布 ...
- 二、Android应用的界面编程(二)布局管理器
一.线性布局所有布局都可以作为容器类使用,因此可以调用多个重载的addView()向布局管理器中添加组件.实际上,我们完全可以用一个布局管理器嵌套到其他布局管理器中---因为布局管理器也继承了View ...
- Android UI组件:布局管理器
为了更好的管理Android应用的用户界面中的组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常,推荐使用布局管理器来管理组件的分布. ...
随机推荐
- Oracle查看表空间使用情况
查看表空间使用情况 select upper(f.tablespace_name) "表空间名", d.tot_grootte_mb "表空间大小(m ...
- Materialized View in Oracle - Concepts and Architecture
List all of MV inoracle: select owner, query, query_len from dba_mviews See content of aMV: select * ...
- javascript每日一练(一)——javascript基础
一.javascript的组成 ECMAScript DOM BOM 二.变量类型 常见类型有:number, string, boolean, undefined, object, function ...
- spring mvc 和 jstl
spring ,jstl 在maven配置文件的配置:<dependency><groupId>org.springframework</groupId><a ...
- Genymotion 插件在 Eclipse 和 Android Studio 中点击后无法初始化 Initialize Engine: failed 解决方法
Genymotion 插件已更新至 1.0.6,目前无法初始化的问题已经解决. ------------------------------------------------------------ ...
- sql: 查询,select
快速查询数据库中拥有那些表项:(类似linux中的ls, ls |grep table_name*)select * from tab where tname like 'YOUR_QERYNAME% ...
- jdbcType与javaType的对应关系
java.sql.Types 值 Java 类型 IBM DB2 Oracle Sybase SQL Informix IBM Content Manager BIGINT java.lang.lon ...
- Android下QQ空间查看大图特效
近期在做一个项目,里面有一个功能是实现Android QQ好友动态里面的缩略图放大,查看大图的效果.用过都知道,这个特效非常赞的,没用过的下载个玩玩吧.我刚開始以为放大的那个大图是一个Activity ...
- jsoncpp 不能处理long类型数据
jsoncpp,是一个c++的解析和生成json的开源工具.假设你的c++程序须要解析或生成json,它会使这个过程变得非常easy! 可是,今天在用jsoncpp进行生成json的时候报了错误,非常 ...
- 使用hadoop ecipse插件须要注意的问题
1.关于run on hadoop的问题: 在未用hadoop eclipse插件前,我以为通过hadoop eclipse 插件不但能够管理hdfs,还能够自己主动打包程序.并帮我自己主动设置Con ...