android RelativeLayout 适用场景和属性
16lz
2022-08-08
RelativeLayout 适用于组件较多,并且组件之间位置关系复杂,需要组件之间通过彼此的位置互相约束来确定位置。
通过RelativeLayout 确定的组件之间的位置,不会因为RelativeLayout 位置的变化而改变。
一、参考网址
http://developer.android.com/reference/android/widget/RelativeLayout.html
http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
二、基本属性
1、需要使用其他组件ID确定位置的属性。
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
android:layout_above | Positions the bottom edge of this view above the given anchor view ID. | ||||||||||
android:layout_alignBaseline | Positions the baseline of this view on the baseline of the given anchor view ID. | ||||||||||
android:layout_alignBottom | Makes the bottom edge of this view match the bottom edge of the given anchor view ID. | ||||||||||
android:layout_alignEnd | Makes the end edge of this view match the end edge of the given anchor view ID. | ||||||||||
android:layout_alignLeft | Makes the left edge of this view match the left edge of the given anchor view ID. | ||||||||||
android:layout_below | Positions the top edge of this view below the given anchor view ID. | ||||||||||
android:layout_alignRight | Makes the right edge of this view match the right edge of the given anchor view ID. | ||||||||||
android:layout_alignStart | Makes the start edge of this view match the start edge of the given anchor view ID. | ||||||||||
android:layout_alignTop | Makes the top edge of this view match the top edge of the given anchor view ID. | ||||||||||
android:layout_toLeftOf | Positions the right edge of this view to the left of the given anchor view ID. | ||||||||||
android:layout_toRightOf | Positions the left edge of this view to the right of the given anchor view ID. | ||||||||||
android:layout_toStartOf | Positions the end edge of this view to the start of the given anchor view ID. | ||||||||||
android:layout_toEndOf | Positions the start edge of this view to the end of the given anchor view ID. | ||||||||||
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
android:layout_centerHorizontal | If true, centers this child horizontally within its parent. | ||||||||||
android:layout_alignParentBottom | If true, makes the bottom edge of this view match the bottom edge of the parent. | ||||||||||
android:layout_alignParentEnd | If true, makes the end edge of this view match the end edge of the parent. | ||||||||||
android:layout_alignParentLeft | If true, makes the left edge of this view match the left edge of the parent. | ||||||||||
android:layout_alignParentRight | If true, makes the right edge of this view match the right edge of the parent. | ||||||||||
android:layout_alignParentStart | If true, makes the start edge of this view match the start edge of the parent. | ||||||||||
android:layout_alignParentTop | If true, makes the top edge of this view match the top edge of the parent. | ||||||||||
android:layout_centerInParent | If true, centers this child horizontally and vertically within its parent. | ||||||||||
android:layout_alignWithParentIfMissing | If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. | ||||||||||
android:layout_centerVertical | If true, centers this child vertically within its parent. | ||||||||||
3、需要设置size的属性
更多相关文章
- android Dialog大小修改
- Android四大基本组件介绍与生命周期
- Android四大组件的理解
- 第三章 Android程序设计基础
- Android开发——Android搜索框架(二)
- android用户界面-组件Widget-地图视图MapView
- Android(安卓)组件资源库
- android用户界面-组件Widget-画廊视图Gallery
- [Android] ACTION_GET_CONTENT与ACTION_PICK的区别