Android開發之五種布局

來源:互聯網
上載者:User

Android開發之五種布局

一、LinearLayout線性布局
1、常見屬性
android:orientation=horizontal:制定線性布局的相片順序
水平 horizontal
垂直 vertical
gravity 控制當前控制項內容顯示地區
layout_gravity 當前控制項在父元素的位置
Layout_weight 額外空間分配(權重)
android:visibility=invisible
控制布局是否顯示
顯示 visible
不顯示,但占空間 invisible
隱藏 gone
2、demo

            
二、RelativeLayout相對布局
1、常見屬性
android:layout_toRightOf 在指定控制項的右邊
android:layout_toLeftOf 在指定控制項的左邊
android:layout_above 在指定控制項的上邊
android:layout_below 在指定控制項的下邊
android:layout_alignBaseline 跟指定控制項水平對齊
android:layout_alignLeft 跟指定控制項靠左對齊
android:layout_alignRight 跟指定控制項靠右對齊
android:layout_alignTop 跟指定控制項頂部對齊
android:layout_alignBottom 跟指定控制項底部對齊
android:layout_alignParentLeft 是否跟父布局靠左對齊
android:layout_alignParentTop 是否跟父布局頂部對齊
android:layout_alignParentRight 是否跟父布局靠右對齊
android:layout_alignParentBottom 是否跟父布局底部對齊
android:layout_centerVertical 在父布局中垂直置中
android:layout_centerHorizontal 在父布局中水平置中
android:layout_centerInParent 在父布局中置中
2、demo
三、AbsoluteLayout絕對布局

1、屬性
android:layout_x 指定控制項在父布局的x軸座標
android:layout_y 指定控制項在父布局的y軸座標
2、demo
四、TableLayout表格版面配置

1、屬性
android:shrinkColumns 收縮列
android:stretchColumns 展開列
android:collapseColumns 隱藏列
android:layout_column 指定列(作用在列的身上)
android:layout_span 合并列(作用在列的身上)
2、demo
                            
五、FrameLayout幀布局
1、特點
幀布局每次添加的控制項都顯示在最上面,最後顯示在介面上的是最後添加的一個控制項
 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.