Android之RelativeLayout相對布局


1、相關術語解釋

1、基本屬性
    gravity :設置容器內組件的對齊方式
    ignoreGravity : 設置該屬性為true的組件,將不受gravity屬性的影響

2、根據父容器定位
    layout_alignParentLeft : 左對齊
    layout_alignParenRight : 右對齊
    layout_alignParentTop : 頂部對齊
    layout_alignParentButtom : 底部對齊
    android:layout_centerHorizontal :水平居中
    android:layout_centerVertical : 垂直居中
    android:layout_centerInParent : 中間位置

3、根據兄弟組件定位
    layout_toLeftOf : 參考組件的左邊
    layout_toRightOf: 參考組件的左邊
    layout_above : 參考組件的上方
    layout_below : 參考組件的下方
    layout_alignTop :對齊參考組件的上邊界
    layout_alignBottom : 對齊參考組件的下邊界
    layout_alignLeft: 對齊參考組件的左邊界
    layout_alignRight : 對齊參考組件的右邊界

4、margin(偏移)
    設置組件與父容器的邊界
    layout_margin 設置組件上下左右的偏移量
    layout_marginLeft 設置組件離左邊的偏移量
    layout_marginRight 設置組件離右邊的偏移量
    layout_marginTop 設置組件離上面的偏移量
    layout_marginButtom 設置組件離下面的偏移量

5、padding(填充)
    設置組件內部元素間的邊距(比如TextView里的字體位置)
    android:padding 往內部元素的上下左右填充一定邊距
    paddingLeft 往內部元素的左邊填充一定邊距
    paddingRight 往內部元素的右方填充一定邊距
    paddingTop 往內部元素的上方填充一定邊距
    paddingBottom 往內部元素的下發填充一定邊距

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM