Android中TableLayout中的布局
来源:互联网 发布:excel数据生成图表 编辑:程序博客网 时间:2024/06/05 15:07
1.在TableLayout下的代码及效果
01
<
TableRow
>
02
<
TextView
android:text
=
"tmacsky"
/>
03
<
TextView
android:text
=
"tmacsky"
/>
04
<
TextView
android:text
=
"tmacsky"
/>
05
</
TableRow
>
06
<
TableRow
>
07
<
Button
android:text
=
"tmacsky"
/>
08
<
Button
android:text
=
"tmacsky"
/>
09
<
Button
android:text
=
"tmacsky"
android:layout_weight
=
"1"
/>
10
</
TableRow
>
11
<
TableRow
>
12
<
EditText
/>
13
<
EditText
/>
14
<
EditText
android:layout_weight
=
"1"
/>
15
</
TableRow
>
单个列布局中只能用layout_weight来拉宽,如果布局很多就有点繁琐了,所以得用到下面的stretchColumns伸缩列
2. Android:stretchColumns 伸缩列
代码和效果:
01
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
02
<
TableLayout
xmlns:android
=
"http://schemas.android.com/apk/res/android"
03
android:layout_width
=
"fill_parent"
04
android:layout_height
=
"wrap_content"
05
android:stretchColumns
=
"0,1,2"
> //(此处表示第1,2,3列都拉宽屏幕)
06
<
TableRow
>
07
<
TextView
android:text
=
"tmacsky1"
/>
08
<
TextView
android:text
=
"tmacsky2"
/>
09
<
TextView
android:text
=
"tmacsky3"
/>
10
</
TableRow
>
11
<
TableRow
>
12
<
Button
android:text
=
"tmacsky1"
/>
13
<
Button
android:text
=
"tmacsky2"
/>
14
<
Button
android:text
=
"tmacsky3"
/>
15
</
TableRow
>
16
<
TableRow
>
17
<
EditText
/>
18
<
EditText
/>
19
<
EditText
/>
20
</
TableRow
>
21
</
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” 位置固定到第三列
转自:http://www.open-open.com/lib/view/open1373595423128.html
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布局学习
- Flex Accessibility 全键盘支持和扩展
- 探秘static——类不需实例化就能用?
- MSP入门实验
- cocos2d-x 3.1.1 学习笔记[1]Label 标签
- bt采集蜘蛛,开源版
- Android中TableLayout中的布局
- win7 IIS 设置共享目录
- 利用DHT网络原理制作bt采集蜘蛛
- controlswitch的创建
- The Python Standard Library » 5. Built-in Types 2. Built-in Functions
- 蹭WiFi掉黑客陷进怎么破
- 列出指定目录所有文件并修改文件名的源代码
- 【C/C++】BinarySearch
- jQuery实现鼠标移上弹出提示框,移出消失