RelativeLayout是相對佈局控件,它包含的子控件將以控件之間的相對位置或者子類控件相對父類容器的位置方式排列。android
1、RelativeLayout -- 相對佈局的16個屬性:
1. 相對於兄弟控件(9個)
- abdroid:layout_toLeftOf = "@id/" 左
- abdroid:layout_toRightOf = "@id/" 右
- abdroid:layout_above = "@id/" 上
- abdroid:layout_bottom = "@id/" 下
對齊佈局
- android:layout_alignLeft = "@id/" 左對齊
- android:layout_alignright = "@id/" 右
- android:layout_alignTop = "@id/" 上
- android:layout_alignBottom = "@id/" 底
- android:layout_alignBaseLine = "@id/" 基準線
2.相對於父控件(7個)
- android:layout_alignParentLeft = "true"
- android:layout_alignParentTop = "true"
- android:layout_alignParentright = "true"
- android:layout_alignParentBottom = "true"
對齊spa
- android:layout_centerInParent = "true" 居中
- android:layout_centerHorizontal = "true" 垂直居中
- android:layout_centerVertical = "true" 水平居中