Android學習筆記之 android:collapseColumns ,android:shrinkColumns 和stretchColumns

來源:互聯網
上載者:User

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>

 

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列去掉,如:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.