TableLayout屬性:
android:collapseColumns:將TableLayout里面**指定的列隱藏**,若有多列需要隱藏,請用逗號將需要隱藏的列序號隔開。
android:stretchColumns:設置**指定的列為可伸展的列,以填滿剩下的多余空白空間**,若有多列需要設置為可伸展,請用逗號將需要伸展的列序號隔開。
android:shrinkColumns:設置**指定的列為可收縮的列。當可收縮的列太寬(內容過多)不會被擠出屏幕**。當需要設置多列為可收縮時,將列序號用逗號隔開。
TableLayout繼承了LinearLayout,本質上是線性布局。表格布局采用行,列形式來管理UI組件,是通過TableRow,其他組件來控制表格的行,列的
每次想TableLayout中添加一個TableRow,該TableRow就是一個表格行,TableRow也是容器,因此可以添加組件,沒添加一個子組件該表格就增加一列。

~~~
<pre name="code" class="html"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".AndroidTableLayoutActivity" >
<!-- 定義第一個表格,指定第2列允許收縮,第3列允許拉伸 -->
<TableLayout
android:id="@+id/tablelayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1"
android:stretchColumns="2" >
<!-- 直接添加按鈕,自己占用一行 -->
<Button
android:id="@+id/btn01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="獨自一行" >
</Button>
<TableRow>
<Button
android:id="@+id/btn02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通" >
</Button>
<Button
android:id="@+id/btn03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="允許被收縮" >
</Button>
<Button
android:id="@+id/btn04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="允許被拉伸允許被拉伸" >
</Button>
</TableRow>
</TableLayout>
<!-- 定義第2個表格,指定第2列隱藏 -->
<TableLayout
android:id="@+id/tablelayout02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:collapseColumns="1" >
<TableRow>
<Button
android:id="@+id/btn05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通" >
</Button>
<Button
android:id="@+id/btn06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="被隱藏列" >
</Button>
<Button
android:id="@+id/btn07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="允許被拉伸" >
</Button>
</TableRow>
</TableLayout>
<!-- 定義第3個表格,指定第2列填滿空白 -->
<TableLayout
android:id="@+id/tablelayout03"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1" >
<TableRow>
<Button
android:id="@+id/btn08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="普通" >
</Button>
<Button
android:id="@+id/btn09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="填滿剩余空白" >
</Button>
</TableRow>
</TableLayout>
</LinearLayout>
~~~
~~~
</pre><pre name="code" class="java"><img src="http://img.blog.csdn.net/20160104200926588?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
~~~
- 前言
- Eclipse搭建android環境及Genymotion模擬器安裝問題解決方法
- 表格布局(TableLayout)及重要屬性
- 幀布局(FrameLayout)及屬性
- layout_width和width,layout_height和height
- UI組件之TextView及其子類
- UI組件之TextView及其子類(一)TextView和EditText
- UI組件之TextView及其子類(二)RadioButton和CheckBox
- UI組件之TextView及其子類(三)ToggleButton和Switch
- UI組件之TextView及其子類(四)AnalogClock,DigitalClock
- UI組件之TextView及其子類(五)計時器Chronometer
- UI組件之ImageView及其子類(一)ImageView顯示圖片
- UI組件之ImageView及其子類(二)ImageButton ,ZoomButton
- UI組件之AdapterView及其子類關系,Adapter接口及其實現類關系
- UI組件之AdapterView及其子類(一)三種Adapter適配器填充ListView
- UI組件之AdapterView及其子類(二)GridView網格視圖的使用
- UI組件之AdapterView及其子類(三)Spinner控件詳解
- UI組件之AdapterView及其子類(四)Gallery畫廊控件使用
- UI組件之AdapterView及其子類(五)ListView組件和ListActivity
- UI組件之AdapterView及其子類(六)ExpandableListView組件和ExpandableListActivity的使用
- UI組件之 ProgressBar及其子類(一)ProgressBar進度條的使用
- UI組件之ProgressBar及其子類(二)SeekBar拖動條和RatingBar星級評分條的使用
- ViewFlipper的功能和用法
- Toast的功能和用法
- TabHost選項卡的 功能和用法
- AlertDialog創建6種對話框的用法
- Android基于監聽的事件處理機制
- Android基于回調的事件處理
- Handler消息傳遞機制(一)
- Handler消息傳遞機制(二)Handler,Loop,Message,MessageQueue的工作原理
- 啟動Activity的兩種方式startActivity和startActivityForResult(一)
- 啟動Activity的兩種方式startActivity和startActivityForResult(二)
- Activity的生命周期理解
- Bundle在Activity之間交換數據
- 通過 Intent 傳遞類對象
- Intent對象詳解(一)
- Intent對象詳解(二)
- 使用指定的Action,Category調用系統Activity
- 使用Action,Data屬性啟動系統Activity
- Android數據存儲的三種方式-SharedPrefrences,File,SQLite