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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

布局管理器 2----- 表格布局

發(fā)布時(shí)間:2025/5/22 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 布局管理器 2----- 表格布局 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

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

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

如果直接向TableLayout中添加組件,那么這個(gè)組件將直接占用一行。

在表格布局中,列的寬度有該列中最寬的那個(gè)單元格決定,整個(gè)表格布局的寬度則取決于父容器的狂度。(默認(rèn)總是占滿父容器本身)

?XML屬性 ?相關(guān)方法 ?說(shuō)明
?android:collapseColumns ?setColumnCollapsed(int,boolean) ?設(shè)置需要被隱藏的列的列序號(hào),多個(gè)列序號(hào)之間用逗號(hào)隔開(kāi)
?android:shrinkColumns ?setShrinkAllColumns(boolean) ?設(shè)置允許被收縮的列的列序號(hào),多個(gè)列序號(hào)之間用逗號(hào)隔開(kāi)
?android:stretchColumn ?setStretchAllColumns(boolean) ?設(shè)置允許被拉伸的列的列序號(hào),多個(gè)列序號(hào)之間用逗號(hào)隔開(kāi)

?

例子:

<?xml version="1.0" encoding="utf-8" ?> - <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - <!-- 定義第一個(gè)表格布局,指定第2列允許收縮,第3列允許拉伸 --> - <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:shrinkColumns="1" android:stretchColumns="2"> - <!-- 直接添加按鈕,它自己會(huì)占一行 --> <Button android:id="@+id/ok1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="獨(dú)自一行的按鈕" /> - <!-- 添加一個(gè)表格行 --> - <TableRow> - <!-- 為該表格行添加3個(gè)按鈕 --> <Button android:id="@+id/ok2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="普通按鈕" /> <Button android:id="@+id/ok3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="允許被收縮的按鈕" /> <Button android:id="@+id/ok4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="允許被拉伸的按鈕" /> </TableRow></TableLayout> - <!-- 定義第二個(gè)表格布局 ,指定第二列隱藏 --> - <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:collapseColumns="1"> - <!-- 直接添加按鈕,它自己會(huì)占一行 --> <Button android:id="@+id/ok5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="獨(dú)自一行的按鈕" /> - <!-- 定義一個(gè)表格行 --> - <TableRow> - <!-- 為該表格行添加3個(gè)按鈕 --> <Button android:id="@+id/ok6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="普通按鈕1" /> <Button android:id="@+id/ok7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="被隱藏的按鈕" /> <Button android:id="@+id/ok8" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="普通按鈕 3" /> </TableRow></TableLayout> - <!-- 定義第三個(gè)表格布局 ,指定第2、3兩列可以被拉伸 --> - <TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="1,2"> - <!-- 直接添加按鈕,它自己會(huì)占一行 --> <Button android:id="@+id/ok9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="獨(dú)自一行的按鈕" /> - <!-- 定義一個(gè)表格行 --> - <TableRow> - <!-- 為該表格行添加3個(gè)按鈕 --> <Button android:id="@+id/ok10" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="普通按鈕" /> <Button android:id="@+id/ok11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="允許被拉伸的按鈕" /> <Button android:id="@+id/ok12" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="允許被拉伸的按鈕" /> </TableRow> - <!-- 定義一個(gè)表格行 --> - <TableRow> - <!-- 為該表格行添加2個(gè)按鈕 --> <Button android:id="@+id/ok13" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="普通按鈕" /> <Button android:id="@+id/ok14" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="允許被拉伸的按鈕" /> </TableRow></TableLayout></LinearLayout>

轉(zhuǎn)載于:https://my.oschina.net/jintiangufei/blog/87620

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的布局管理器 2----- 表格布局的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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