RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left of center).
A RelativeLayout is a very powerful utility for designing a user interface because it can eliminate nested view groups and keep your layout hierarchy flat, which improves performance. If you find yourself using several nested LinearLayout groups, you may be able to replace them with a single RelativeLayout.
Some of the many layout properties available to views in a RelativeLayout include:
- If “true”, makes the top edge of this view match the top edge of the parent.
- If “true”, centers this child vertically within its parent.
- Positions the top edge of this view below the view specified with a resource ID.
- Positions the left edge of this view to the right of the view specified with a resource ID.
The value for each layout property is either a boolean to enable a layout position relative to the parent RelativeLayout or an ID that references another view in the layout against which the view should be positioned.