Android布局之表格布局TableLayout詳解
本文實(shí)例為大家分享了Android表格布局TableLayout的具體代碼,供大家參考,具體內(nèi)容如下
1.TableLayout
TableLayout表格布局模型以行列的形式管理子控件,每一行為一個(gè)TableRow的對(duì)象, 當(dāng)然也可以使一個(gè)View的對(duì)象
2.TableLayout的屬性(全局屬性)
android:collapseColumns=”1,2”
隱藏從0開(kāi)始的索引列,列之間必須用逗號(hào)隔開(kāi)1,2
android:shrinkColumns=”1,2”
收縮從0開(kāi)始的索引列,當(dāng)可收縮的列太寬(內(nèi)容太多時(shí))不會(huì)被擠出屏幕,列之間
用逗號(hào)隔開(kāi)1,2,你可以通過(guò)”*”代替收縮所有列,注意一列能同時(shí)表示收縮和拉伸
android:stretchColumns=”1,2”
拉伸從0開(kāi)始的索引列,以填滿剩下的多余空白空間,列之間必須用逗號(hào)隔開(kāi),1,2,
你可以通過(guò)”*”代替收縮所有列,注意一列能同時(shí)表示收縮和拉伸
3.TableLayout的局部屬性(內(nèi)部控件所用屬性)
android:layout_column=”1” 該控件顯示在第1列
android:layout_span=”2” 該控件占據(jù)兩列
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:collapseColumns="0" android:shrinkColumns="4"> <TableRow android:id="@+id/tablerow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" /> <Button android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" /> <Button android:id="@+id/button7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button4" /> <Button android:id="@+id/button8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button555555555555555555555555" /> </TableRow> </TableLayout>
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="*"> <TableRow android:id="@+id/tablerow1" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" /> <Button android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" /> </TableRow> </TableLayout>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
淺析Android 快速實(shí)現(xiàn)圖片壓縮與上傳功能
在Android對(duì)手機(jī)相冊(cè)中的圖片的壓縮和上傳到服務(wù)器上,這樣的功能在每個(gè)app開(kāi)發(fā)中都會(huì)有這樣的需求.所以今天就對(duì)android端怎么快速實(shí)現(xiàn)圖片壓縮和上傳進(jìn)行簡(jiǎn)單的分析2017-08-08Flutter定義tabbar底部導(dǎo)航路由跳轉(zhuǎn)的方法
這篇文章主要為大家詳細(xì)介紹了Flutter定義tabbar底部導(dǎo)航路由跳轉(zhuǎn)的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07Android開(kāi)發(fā)中類(lèi)加載器DexClassLoader的簡(jiǎn)單使用講解
這篇文章主要介紹了Android開(kāi)發(fā)中類(lèi)加載器DexClassLoader的簡(jiǎn)單使用講解,DexClassLoader可以看作是一個(gè)特殊的Java中的ClassLoader,需要的朋友可以參考下2016-04-04分析CmProcess跨進(jìn)程通信的實(shí)現(xiàn)
CmProcess是Android一個(gè)跨進(jìn)程通信框架,無(wú)需進(jìn)行bindService()操作,不用定義Service,也不需要定義aidl。 支持IPC級(jí)的 Callback,并且支持跨進(jìn)程的事件總線,可同步獲取服務(wù),采用面向接口方式進(jìn)行服務(wù)注冊(cè)與調(diào)用,服務(wù)調(diào)用方和使用者完全解耦2021-06-06Android?WebView開(kāi)發(fā)之自定義WebView工具框
在WebView頁(yè)面長(zhǎng)按時(shí)會(huì)彈出一個(gè)復(fù)制框,有的時(shí)候里面的item不是我們想要,這個(gè)時(shí)候我們就可以自定義一個(gè)工具框。本文就將介紹如何通過(guò)WebView自定義工具框,需要的朋友可以參考一下2021-12-12Android開(kāi)發(fā)仿咸魚(yú)鍵盤(pán)DEMO(修改版)
本文給大家分享一段代碼關(guān)于android開(kāi)發(fā)高仿咸魚(yú)鍵盤(pán)修改版的實(shí)例代碼,代碼簡(jiǎn)單易懂,非常實(shí)用,需要的朋友參考下吧2016-11-11Android項(xiàng)目中實(shí)體類(lèi)entity的作用詳解
這篇文章主要介紹了Android項(xiàng)目中實(shí)體類(lèi)entity的作用詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-04-04Android 7.0系統(tǒng)webview 顯示https頁(yè)面空白處理方法
今天小編就為大家分享一篇Android 7.0系統(tǒng)webview 顯示https頁(yè)面空白處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-07-07Android開(kāi)發(fā)實(shí)現(xiàn)圖片圓角的方法
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)圖片圓角的方法,涉及Android針對(duì)圖形圖像的相關(guān)操作技巧,需要的朋友可以參考下2016-10-10