Android中TableLayout中的布局
来源:互联网 发布:java求两个时间差 秒 编辑:程序博客网 时间:2024/05/27 10:43
1.在TableLayout下的代码及效果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<TableRow>
<TextView android:text="tmacsky" />
<TextView android:text="tmacsky" />
<TextView android:text="tmacsky" />
</TableRow>
<TableRow>
<Button android:text="tmacsky" />
<Button android:text="tmacsky" />
<Button android:text="tmacsky" android:layout_weight="1" />
</TableRow>
<TableRow>
<EditText />
<EditText />
<EditText android:layout_weight="1"/>
</TableRow>
单个列布局中只能用layout_weight来拉宽,如果布局很多就有点繁琐了,所以得用到下面的stretchColumns伸缩列。
代码和效果:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2" > //(此处表示第1,2,3列都拉宽屏幕)
<TableRow>
<TextView android:text="tmacsky1" />
<TextView android:text="tmacsky2" />
<TextView android:text="tmacsky3" />
</TableRow>
<TableRow>
<Button android:text="tmacsky1" />
<Button android:text="tmacsky2" />
<Button android:text="tmacsky3" />
</TableRow>
<TableRow>
<EditText />
<EditText />
<EditText />
</TableRow>
</TableLayout>
由此可以想象伸缩列其实就是用weight来封装的。
3. android:collapseColumns缩进列
将第2个例子里的Android:stretchColumns缩进下加一行代码:
android:collapseColumns="0"
意思就是缩进第一列效果:
4,如果按钮里文字过多,则会出现下面这种情况:
超出屏幕了;这个时候如果想让按钮里的文字换行不超出屏幕则可以:
在第二个例子的Android:stretchColumns添加一行代码:
android:shrinkColumns="2"
5.实现下面的效果
在第二个例子里的EditText代码改成这样:
<TableRow>
<EditText android:layout_span="2"/>
<EditText android:layout_column="2"/>
</TableRow>
Layout_span=”2” 伸展2倍
Layout_column=”2” 位置固定到第三列
0 0
- Android中TableLayout中的布局
- Android中TableLayout中的布局
- Android中TableLayout中的布局
- Android中的TableLayout布局
- Android中的表格布局TableLayout
- Android布局之TableLayout
- android-TableLayout 表格布局
- tablelayout-android布局
- Android---tableLayout(表单布局)
- android TableLayout布局
- Android之TableLayout布局
- Android-TableLayout布局
- android,TableLayout布局
- Android 表格布局<TableLayout>
- android:TableLayout表格布局
- android:TableLayout表格布局
- android------布局+TableLayout
- Android TableLayout布局学习
- Hadoop 2.7.1 集群模式安装【三】环境配置实战
- 如何在 CentOS 7 上安装 Redis 服务器
- dd命令详解
- PHP study2014 配置多个站点(主要是修改 vhosts.conf文件,然后重启。)
- 本人在安装oracle10g客户端程序的时候发生了错误
- Android中TableLayout中的布局
- zhphp framework (十四) widget 挂件
- 第一章 你的第一行代码
- mark--难舍GStc
- GitHub中配置ssh遇到的问题解决
- excel复制到plsql
- Windows 10_x64 PL/SQL 链接64位 Oracle
- Android 学习资源收集
- OC-028.ARC自动内存管理的自动释放池