導航:首頁 > 操作系統 > 安卓表格布局的列怎麼確定

安卓表格布局的列怎麼確定

發布時間:2023-03-24 01:17:52

android 常見布局

Android六大基本布局分別是:線性布局LinearLayout、表格布局TableLayout、相對布局RelativeLayout、層布局FrameLayout、絕對布局AbsoluteLayout、網格布局GridLayout。其中,表格布局是線性布局的子類。網格布局是android 4.0後新增的布局。
在手機程序設計中,絕對布局基本上不用,用得相對較多的是線性布局和相對布局。

padding是站在父view的角度描述問題,它規定它裡面的內容必須與這個父view邊界的距離。margin則是站在自己的角度描述問題,規定自己和其他(上下左右)的view之間的距離,如果同一級只有一個view,那麼它的效果基本上就和padding一樣了。

顯示特點:所有子控制項按照橫向或者豎向依次排列

left(左)、right(右)、top(上)、bottom(下)、center(中心)、
enter_vertical(豎向中心)、center_horizontal(橫向中心)

left(左)、right(右)、top(上)、bottom(下)、center(中心)、
enter_vertical(豎向中心)、center_horizontal(橫向中心)

子控制項的用法:android:layout_weight="1" 多個控制項同時使用,可以實現平分的效果

顯示特點:和LinearLayout布局相似,所有子控制項默認顯示在RelativeLayout的左上角

layout_toRightOf 在指定控制項的右邊
layout_toLeftOf 在指定控制項的左邊
layout_above 在指定控制項的上邊
layout_below 在指定控制項的下邊子控制項對齊關系

layout_alignRight 與指定控制項右對齊
layout_alignLeft 與指定控制項左對齊
layout_alignTop 與指定控制項上對齊

layout_centerInParent 與父容器中間對齊 pairunte
layout_centerVertical 與父容器豎向中心對齊
layout_centerHorizontal 與父容器橫向中心對齊
layout_alignParentLeft 與父容器左邊對齊
layout_alignParentTop 與父容器上邊對齊
layout_alignParentRight 與父容器右邊對齊
layout_alignParentBottom 與父容器下邊對齊

顯示特點:所有子控制項默認在GridLayout中橫向依次排列,當只等每行的列數時,到達指定列數
會自動換行顯示。

layout_column 在網格的第幾列
layout_row 在網格的第幾行
layout_columnSpan 跨列
layout_rowSpan 跨行
layout_gravity 在一個網格中的重心位置
columnCount 每行列總數

顯示特點:所有的子控制項默認顯示在FrameLayout的左上角,會重疊在一起顯示。

layout_gravity(設置給子控制項,調整控制項在容器內的重心)
常用值:
left(左)、 right(右)、
top(上)、 bottom(下)、
center(中心)、 center_vertical(豎向中心)
center_horizontal(橫向中心)

表格布局和網格布局類似,但是需要注意的是,表格布局不能跨行,只能跨列

Ⅱ 在安卓中什麼是線性布局,表格布局,相對布局求詳細答案,急急急!!!!

線性布局(LinearLayout):在該標簽下的所有子元素會根據orientation屬性的值來決定是按行或者是按列來逐個顯示。代碼示例如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test" />

</LinearLayout>
而相對布局,則是根據控制項的相對位置而言,比如居於按鈕的左側或者右側,示例如下:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
android:layout_alignTop="@id/button1"
android:text="@string/hello_world" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/app_name" />

</RelativeLayout>
分享

Ⅲ android ui開發中,tablelayout的列數是怎麼計算的

TableLayout,表格布局採用行列形式管理UI組件,TableLayout不需要明確地聲明有多少行和列,而是通過添加TableRow、其它組件來控製表格的行數、列數。
每次向TableLayout添加一個TableRow,就是在向表格添加一行,TableRow也是容器,可以向TableRow中添加組件,每添加一個組件,即是添加一列。
如果直接向TableLayout添加組件,則認為這個組件佔用一行。
表格布局中列的寬度即是每一列中最寬的組件的寬度。
使用前:

\

使用後:

\

<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:text="最近聯備碰系人"
android:id="@+id/button4"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

<Button
android:text="聯系人"
android:id="@+id/button5"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

<Button
android:text="分組"
android:id="@+id/button5"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

</TableRow>

</TableLayout>
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:text="最近聯系人"
android:id="@+id/button4"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

<Button
android:text="聯系人"
android:id="@+id/button5"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

<Button
android:text="分組"
android:id="@+id/button5"
android:layout_width="1dip"
android:layout_height="wrap_content"></Button>

</TableRow>

</TableLayout>
TableLayout 增加一個屬性 android:stretchColumns="*"伍辯 表示所有列都要自動拉伸,以便適應屏幕寬度。

它的值即可以是數字,也可以是*,注意數字是從仿橘談0開始的,即:android:stretchColumns="1" 是設置 TableLayout所有行的第二列為擴展列。

上面我們會看到 第1列的按鈕比其他列的按鈕要寬,如果我們想都一樣寬如何辦呢?

一個簡單辦法:

android:layout_width="1dip"

Ⅳ android 表格布局怎麼顯示出表格線,怎麼樣設置跨幾行跨幾列

intent可以傳值的,intent.putextra();把你的評論參數放進去,在接收頁面直接調用getintent獲得這個intent,然後把值取出來就可以了

Ⅳ android實現方格布局

應該使用表格布局。
表格布局即,tableLayout,表格布局通過行、列的形式來管理UI組件,TablelLayout並不需要明確地聲明包含多少行、多少列,而是通過TableRow,以及其他組件來控製表格的行數和列數, TableRow也是容器,因此可以向TableRow裡面添加其他組件,沒添加一個組件該表
格就增加一列。
如果想
TableLayout裡面添加組件,那麼該組件就直接佔用一行。
在表格布局中,列的寬度由該列中最寬的單元格決定,整個表格布局的寬度取決於父容
器的寬度(默認是占滿父容器本身)。
TableLayout繼承了LinearLayout,因此他完全可以支持LinearLayout所支持的全部XML屬性,除此之外TableLayout還支持以下屬性:
XML屬性相關用法說明
1. andriod:collapseColumns setColumnsCollapsed(int ,boolean) 設置需要隱藏的列的序列號,多個用逗號隔開
2.android:shrinkColumns setShrinkAllColumns(boolean)設置被收縮的列的序列號,多個用逗號隔開
3.android:stretchColimns setSretchAllColumnds(boolean)設置允許被拉伸的列的序列號,多個用逗號隔開

Ⅵ android 表格布局怎樣設置某列比例

你好,看了你的布局,大概分成3部分

,第一部分是標題,第二部分是薯掘左邊的部分,

第三部分是右側部分,那麼問題就頌手敬分3個布局解決就好: ----------------這部分寫左側的內容-------------------- ---------------- 這野慎部分寫右側的內容--------------...

Ⅶ Android怎樣獲取TableLayout TableRow的第幾行第幾列

android-TableLayout以及TableRow的使用

TableLayout是一種可以製作表格的布局,它和GridLayout的區別是GridLayout只能制定每一列寬度一樣的表格布局,而TableLayout能夠制定各列寬度不一樣的表格布局。

TableLayout的主要屬性:

android:collapseColumns=」0,1」 隱藏第0列和第1列
android:stretchColumns=」0,1」 第0列和第1列可以向行方向擴展
android:stretchColumns=」*」 所有列可爛銀拿以向行方向擴展
android:shrinkColumns=」0,1」 第0列和第1列可以飢搭向列方向擴展

TableRow的子控制項的主要屬性:

android:layout_column=」1」搏畝 該控制項顯示在第1列
android:layout_span=」2」 該控制項占據2列

詳細

閱讀全文

與安卓表格布局的列怎麼確定相關的資料

熱點內容
鬼叫春為什麼吃了餅變黃牛。 瀏覽:146
女子穿越與多個男主在一起 瀏覽:734
電影刪減視頻去哪裡看 瀏覽:638
韓國電影兩個當兵的救一個女的 瀏覽:305
大遲度未刪電影 瀏覽:912
金花媛 寡糖 瀏覽:359
pdf的application 瀏覽:125
pdf數理邏輯 瀏覽:885
歐美愛情喜劇電影 瀏覽:194
主角叫李天的小說 瀏覽:574
台灣風情片 瀏覽:468
xcode新版編譯運行 瀏覽:182
原版純英文字幕電影 瀏覽:231
阿里雲如何做到雲伺服器獨立ip 瀏覽:708
單片機進制教案 瀏覽:476
有什麼好的演算法書 瀏覽:157
到達市電影院英語 瀏覽:135
韓國電影男的進健房找女教練 瀏覽:10
國內十個免費網站 瀏覽:703
雙女主的小說 瀏覽:545