Android中的表格布局TableLayout
表格布局最基本的三个属性:
XML代码实例:
<?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" >
<!-- 定义第一个表格布局,指定第2列同意收缩,第3列同意拉伸 -->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="2"
>
<!-- 直接加入button,它自己会占一行 -->
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ok1"
android:text="独"
/>
<!-- 加入一个表格行 -->
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<Button android:id="@+id/ok2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="普"/>
<Button android:id="@+id/ok3" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="收"/>
<Button android:id="@+id/ok4" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="拉"/>
</TableRow>
</TableLayout> <!-- 定义第二个表格布局,指定第2列隐藏 -->
<TableLayout android:id="@+id/TableLayout02" android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:collapseColumns="1"
>
<!-- 直接加入button,它自己会占一行 -->
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="独"
/>
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<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> <!-- 定义第三个表格布局,指定第2列和第三列同意被拉伸 -->
<TableLayout android:id="@+id/TableLayout03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1,2" android:layout_marginTop="30dp"
>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="独"
/>
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="普通button"/>
<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>
<!-- 定义一个表格行 -->
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content">
<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>
效果:
总结:
假设没实用tableRow,直接用组件,将自己独占一行,而且填充父窗体
而假设用tableRow,上下两行各列将对齐。
Android中的表格布局TableLayout的更多相关文章
- .Net程序猿玩转Android开发---(8)表格布局TableLayout
表格布局TableLayout是Android中比較经常使用的一个布局控件,既然是表格,肯定有行和列,TableLayout中的行有TableRow组成.列依据每行控件的数量来确定 假如第一行有3个控 ...
- Android 自学之表格布局 TableLayout
表格布局(TableLayout),表格布局采用行.列的形式来管理UI组件,TableLayout并不需要明确的声明多少行,多少列,而是通过TableRow.其他组件来控制表格的行数和列数. 每次想T ...
- Android中常用的布局
一般分为5大类. Android中所有的空间第一字母都是大写 1.线性布局 LinearLayout 2.相对布局 RelativeLayout 3.帧布局--分层显示 FrameLayout 4. ...
- Android 中常用的布局
一.线性布局----LinearLayout horizontal 水平 <?xml version="1.0" encoding="utf-8"?& ...
- Android中的五大布局
Android中的五大布局 1.了解布局 一个丰富的界面总是要由很多个控件组成的,那我们如何才能让各个控件都有条不紊地 摆放在界面上,而不是乱糟糟的呢?这就需要借助布局来实现了.布局是一种可用于放置很 ...
- android中的常用布局管理器(三)
接上篇博客 (5)TableLayout 表格布局管理器 在android中,线性布局和表格布局用的是最多的. 在很多的输出操作中,往往会使用表格的形式对显示的数据进行排版,tablelayo ...
- Android中的LinearLayout布局
LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了, 线性布局是按照垂直方向(vertical)或水平方向 ...
- Android 表格布局<TableLayout>
表格布局即,tableLayout,表格布局通过行.列的形式来管理UI组件,TablelLayout并不需要明确地声明包含多少行.多少列,而是通过TableRow,以及其他组件来控制表格的行数和列数, ...
- Android开发5:布局管理器2(表格布局TableLayout)
版本:Android4.3 API18 学习整理:liuxinming 概念 TableLayout继承了LinearLayout,因此它的本质依然是线性布局管理器. 表格布局采 ...
随机推荐
- 用KnockoutJS实现ToDoMVC代码分析
体验地址 Knockout 版todo web app在线体验 http://todomvc.com/examples/knockoutjs/ 源码地址 项目源码地址,此地址包含了各种JS框架实现的t ...
- windows phone 7 客户端和web的交互(WebBrowser的使用)
原文:windows phone 7 客户端和web的交互(WebBrowser的使用) 前几天看到淘宝的Android客户端,有种促销的功能,当点击促销的时候连接的淘宝促销wap页面,然后点击商品后 ...
- Android permission 访问权限
程序执行需要读取到安全敏感项必需在androidmanifest.xml中声明相关权限请求, 完整列表如下: android.permission.ACCESS_CHECKIN_PROPERTIES ...
- POJ 1515 Street Directions
题意: 一幅无向图 将尽量多的无向边定向成有向边 使得图强连通 无向图保证是连通的且没有重边 思路: 桥必须是双向的 因此先求边双连通分量 并将桥保存在ans中 每一个双连通分量内的边一定都 ...
- iOS很重要的 block回调
刚刚进入ios开发行业,发现开发中要用到大量的block回调,由此可见它的重要性.学习它之前我也是网上找的资料,推荐这篇文章http://blog.csdn.net/mobanchengshuang/ ...
- JDK8在Java转让Javascript脚本引擎动态地定义和运行代码
import java.lang.*; import java.util.Arrays; import java.util.List; import javax.script.Invocable; i ...
- 从lca到树链剖分 bestcoder round#45 1003
bestcoder round#45 1003 题,给定两个点,要我们求这两个点的树上路径所经过的点的权值是否出现过奇数次.如果是一般人,那么就是用lca求树上路径,然后判断是否出现过奇数次(用异或) ...
- erlang集群IP及port管理
erlang集群是依靠epmd维护的,epmd是erlang集群节点间port映射的守护进程.负责维护集群内的节点连接.提供节点名称到IP地址及port的解析服务. epmd 自己定义port号 ep ...
- 【原创】leetCodeOj --- Sliding Window Maximum 解题报告
天,这题我已经没有底气高呼“水”了... 题目的地址: https://leetcode.com/problems/sliding-window-maximum/ 题目内容: Given an arr ...
- JavaScript 常见陷阱
JavaScript中的一些特性和通常我们想象的不太一样.这里我总结了一些有悖直觉的语言特性. 1 数组 1.1 数组的遍历 在直接支持for a in b的语言中,比方Python/Ruby里的a的 ...