文章插圖

文章插圖
TableLayout(表格布局)
Android中的表格布局與HTML中的表格標簽< table >< tr >< td >相似,通過使用表格的行與列來排列組件 。如果一行上有多個組件的話,就要在TableLayout中添加一個TableRow的容器,把組件都丟到里面!一個Tablerow一行,有多少列則是看TableRow中的組件個數 。
常用屬性
android:collapseColumns:隱藏某一列
android:shrinkColumns:允許某一列收縮
android:stretchColumns:拉伸某一列
這三個屬性的列號都是從0開始計算的,如shrinkColunmns = “3”,對應的是第四列,可以設置多個,用逗號隔開比如”0,3″,如果是所有列都生效,用”*”號即可 。
android:layout_column=”3″:表示的就是跳過第三個,直接顯示到第四個格子處,從1開始計算 。
android:layout_span=”2″:表示合并2個單元格,也就說這個組件占2個單元格 。
看代碼
<TableLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center_vertical"android:stretchColumns="2"android:shrinkColumns="1"><TableRowandroid:layout_width="match_parent"android:layout_height="match_parent"><Buttonandroid:id="@+id/button7"android:layout_width="139dp"android:layout_height="117dp"android:text="Button1" /><Buttonandroid:id="@+id/button6"android:layout_width="139dp"android:layout_height="117dp"android:text="Button2" /><Buttonandroid:id="@+id/button4"android:layout_width="139dp"android:layout_height="117dp"android:text="Button3" /></TableRow><TableRowandroid:layout_width="match_parent"android:layout_height="match_parent"><Buttonandroid:id="@+id/button9"android:layout_width="139dp"android:layout_height="117dp"android:text="Button4" /><Buttonandroid:id="@+id/button8"android:layout_width="139dp"android:layout_height="117dp"android:text="Button5" /><Buttonandroid:id="@+id/button5"android:layout_width="139dp"android:layout_height="117dp"android:text="Button6" /></TableRow></TableLayout>效果圖幀布局是最為簡單的一種布局,該布局為每個加入其中的控件創建一個空白區域,稱為一幀,每個控件占據一幀 。采用幀布局時,所有控件都默認顯示在屏幕左上角,并按照先后放入的順序重疊擺放,先放入的將會在最底層,后放入的控件顯示在最頂層 。幀布局使用于圖層設計 。
屬性
foreground :設置幀布局容器的前景圖像
【安卓中表格布局方法 安卓開發里表格布局怎么建立】foregroundGravity :屬性設置圖像的顯示位置
看代碼
<FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:foreground="@mipmap/ic_launcher"android:foregroundGravity="bottom"><TextViewandroid:id="@+id/textView"android:layout_width="460dp"android:layout_height="336dp"android:background="@color/colorAccent"android:text="TextView" /><TextViewandroid:id="@+id/textView2"android:layout_width="332dp"android:layout_height="242dp"android:background="@color/colorPrimary"android:text="TextView" /></FrameLayout>效果圖- c語言軟件哪個好用手機 c語言軟件哪個好用中文
- 2021年陰歷幾月幾日鬼節,2021中元節出生的孩子好嗎
- N號房付費會員中有人氣藝人有誰,N號房付費會員名單
- 運動鞋品牌,中國最有名氣的十大運動鞋品牌?
- 什么米煮飯好吃
- 八字情話短語帶樂的,我中有你,你中有我
- 冬季中午做到四個字塑身保健兩不誤
- 七個動作家中做 勝過高價請大夫
- 電腦辦公軟件表格哪個好用 最好用的表格軟件excel
- 黃豆怎么燒
