日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android表格布局(Table Layout)

發(fā)布時(shí)間:2025/4/16 Android 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android表格布局(Table Layout) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Android表格布局(Table Layout)

?

先來看布局管理器之間繼承關(guān)系圖:


圖1

可知TableLayout繼承了LinearLayout,所以表格布局本質(zhì)上依然是線性管理器。

?

表格布局采用行、列的形式來管理組件,它并不需要明確地聲明包含了多少行、多少列,而是通過添加TableRow、其他組件來控制表格的行數(shù)和列數(shù)。

?

每向TableLayout添加一個(gè)TableRow,該TableRow就是一個(gè)表格行,TableRow也是容器,因此它也可以不斷地添加組件,每添加一個(gè)子組件該表格就添加一列。

?

TableLayout一般以下面兩種方式實(shí)現(xiàn):

(1)??自己作為最頂層父容器

<!--定義一個(gè)TableLayout,有兩行第1列所有單元格的寬度可以被收縮,以保證該表格能適應(yīng)父容器的寬度第2列所有單元格的寬度可以拉伸,以保證能完全填滿表格空余空間--> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/TableLayout1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:shrinkColumns="1"android:stretchColumns="2"><!--這是此TableLayout的第1行,沒有使用TableRow,直接添加一個(gè)Button,那么次Button自己占用整行 --><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="獨(dú)自一行的按鈕1"/><!-- 這是第2行,先添加一個(gè)TableRow,并為TableRow添加三個(gè)Button,也就是此行包含三列 --><TableRow><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="普通按鈕1"/><Buttonandroid:id="@+id/button3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被收縮的按鈕1"/><Buttonandroid:id="@+id/button4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被拉伸的按鈕1"/></TableRow><!--這是此TableLayout的第3行,沒有使用TableRow,直接添加一個(gè)Button,那么次Button自己占用整行 --><Buttonandroid:id="@+id/button5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="獨(dú)自一行的按鈕2"/><!-- 這是第4行,先添加一個(gè)TableRow,并為TableRow添加三個(gè)Button,也就是此行包含三列 --><TableRow><Buttonandroid:id="@+id/button6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="普通按鈕2"/><Buttonandroid:id="@+id/button7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被收縮的按鈕2"/><Buttonandroid:id="@+id/button8"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被拉伸的按鈕2"/></TableRow></TableLayout>

效果如下:


圖2

這里只有一個(gè)TableLayout,如果我們想單獨(dú)控制地4行,比如想把“普通按鈕2”隱藏,也就是增加android:collapseColumns="0",這樣會(huì)把“普通按鈕1”,這一列也隱藏了,如下圖:


圖3

但如果要實(shí)現(xiàn)只“普通按鈕2”這列,我們來看下面的實(shí)現(xiàn)

?

(2)??LinearLayout作為TableLayout的容器

?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent">--><!--定義第1個(gè)TableLayout,有兩行第1列所有單元格的寬度可以被收縮,以保證該表格能適應(yīng)父容器的寬度第2列所有單元格的寬度可以拉伸,以保證能完全填滿表格空余空間--> <TableLayoutandroid:id="@+id/TableLayout1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:shrinkColumns="1"android:stretchColumns="2"><!--這是此TableLayout的第1行,沒有使用TableRow,直接添加一個(gè)Button,那么次Button自己占用整行 --><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="獨(dú)自一行的按鈕1"/><!-- 這是第2行,先添加一個(gè)TableRow,并為TableRow添加三個(gè)Button,也就是此行包含三列 --><TableRow><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="普通按鈕1"/><Buttonandroid:id="@+id/button3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被收縮的按鈕1"/><Buttonandroid:id="@+id/button4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被拉伸的按鈕1"/></TableRow></TableLayout> <!--定義第2個(gè)TableLayout,有兩行第1列所有單元格的寬度可以被收縮,以保證該表格能適應(yīng)父容器的寬度第2列所有單元格的寬度可以拉伸,以保證能完全填滿表格空余空間--> <TableLayoutandroid:id="@+id/TableLayout2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:collapseColumns="0"android:shrinkColumns="1"android:stretchColumns="2"><!--這是此TableLayout的第3行,沒有使用TableRow,直接添加一個(gè)Button,那么次Button自己占用整行 --><Buttonandroid:id="@+id/button5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="獨(dú)自一行的按鈕2"/><!-- 這是第4行,先添加一個(gè)TableRow,并為TableRow添加三個(gè)Button,也就是此行包含三列 --><TableRow><Buttonandroid:id="@+id/button6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="普通按鈕2"/><Buttonandroid:id="@+id/button7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被收縮的按鈕2"/><Buttonandroid:id="@+id/button8"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="被拉伸的按鈕2"/></TableRow></TableLayout></LinearLayout>

效果如下:


圖4

?

通過在第2個(gè)TableLayout中增加android:collapseColumns="0"實(shí)現(xiàn),這里需要主要的是LinearLayout的android:orientation屬性值的設(shè)置,如果沒有這一項(xiàng)或是其值為horizontal,那么后面兩行都看不到,因?yàn)槭且运椒较蚺帕械?#xff0c;后面兩行顯示在前兩行的右邊,看不到。

總結(jié)

以上是生活随笔為你收集整理的Android表格布局(Table Layout)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 久久天天东北熟女毛茸茸 | 乱妇乱女熟妇熟女网站 | 啪啪资源 | 日韩小视频网站 | 毛茸茸毛片 | 亚洲 在线 | 天天澡天天狠天天天做 | 看了下面会湿的视频 | 欧美韩国日本一区 | 天堂中文在线观看视频 | zoo性欧美 | 91看片黄| 99精品国产99久久久久久97 | 五月婷综合网 | 在线视频a| 精品亚洲天堂 | 法国空姐电影在线观看 | 亚洲少妇自拍 | 网址你懂的在线 | 热99精品视频 | 亚洲香蕉 | 亚洲a影院| 久久综合国产 | 人妻少妇精品无码专区久久 | 亚洲第一综合网站 | 天天射天天干 | 一级在线播放 | 国产精华一区二区三区 | www.日本在线 | 欧美日韩精品一区二区 | 少妇人妻无码专区视频 | 天堂影音 | 在线观看国产亚洲 | 国产人成无码视频在线观看 | 漂亮人妻洗澡被公强 日日躁 | 内地级a艳片高清免费播放 91在线精品一区二区 | 韩国三级bd高清中字2021 | av黄在线| 国产精品一区二区三区在线看 | 成人做受黄大片 | 国产精品一二三区视频 | 欧美日韩一区二区三区在线 | 国产精品成人久久电影 | 四虎一区二区三区 | 黄色小视频在线免费观看 | 99爱精品视频 | 黄色大片免费观看视频 | 男生女生羞羞网站 | 麻豆传谋在线观看免费mv | 无遮挡的裸体按摩的视频 | 精品视频免费观看 | 国产精品久久久久久人 | 亚洲成人免费观看 | 亚洲福利视频导航 | 日本韩国毛片 | 日韩69视频 | porn亚洲 | 五月激情五月婷婷 | 黄色国产小视频 | 亚洲天堂一区二区三区四区 | 国产成人综合在线 | 精品久久久av | 激情宗合网 | av基地| 亚欧在线免费观看 | 日本在线观看一区二区三区 | 人人妻人人澡人人爽人人精品 | 国产明星换脸xxxx色视频 | 欧美在线视频一区二区三区 | 精品国产乱码久久久久 | 午夜老司机福利 | 一级 黄 色 片69 | 久久国产精品免费看 | 久操福利视频 | 亚洲一区二区国产 | 毛茸茸亚洲孕妇孕交片 | 小宵虎南在线观看 | 永久看看免费大片 | 欧美高清videos高潮hd | 小sao货水好多真紧h无码视频 | 97国产资源 | 少妇高潮一区二区三区99刮毛 | 国产福利精品一区 | 午夜影院免费看 | 久久免费看少妇高潮 | 欧美成人精精品一区二区频 | 丰满少妇乱子伦精品看片 | 午夜免费福利在线观看 | 国产稀缺精品盗摄盗拍 | 久久久九九 | 久久亚洲aⅴ无码精品 | 久久与婷婷 | 99cao | 亚洲色成人www永久网站 | 亚洲国产精品久久人人爱 | 精精国产 | 成人www.| 欧美日韩免费高清一区色橹橹 | 色婷婷狠 |