android:stretchColumns用法

TableLayout是一個使用複雜的佈局,最簡單的用法就僅僅是拖拉控件做出個界面,但實際上,會經常在代碼裏使用TableLayout,例如做出表格的效果。本文主要介紹TableLayout的基本使用方法。

< ?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="fill_parent"
>
<TableRow>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:layout_column="0"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button2"
android:layout_column="1"/>
</TableRow>
</TableLayout>

www.2cto.com
 

 

\

1 android:stretchColumns = "指定的列" ------->以第0行爲序,儘量把指定的列填充空白部分

設置stretchColumns=0,則結果如下圖,第0列被儘量填充

\

設置stretchColumns=1,則結果如下圖,第1列被儘量填充

 

\

2 android:shrinkColumns = "指定的列":以第0行爲序,自動延伸指定的列填充可用部分

當LayoutRow裏面的控件還沒有佈滿佈局時,shrinkColumns不起作用,如下圖

\

當LayoutRow裏面的控件還沒有佈滿佈局時(改寫一下第三個Button的內容)

\

3 android:collapseColumns = “指定的列” 第0行爲序,隱藏指定的列>

android:collapseColumns該屬性爲空時,如下圖:

\

android:collapseColumns=“0” 意思是把第0列去掉,如下圖:

\

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章