Relative Layout View

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.

 

Positioning Views

Some of the many layout properties available to views in a RelativeLayout include:

  1. android:layout_alignParentTop
  • If “true”, makes the top edge of this view match the top edge of the parent.
  • android:layout_centerVertical
  • If “true”, centers this child vertically within its parent.
  • android:layout_below
  • Positions the top edge of this view below the view specified with a resource ID.
  • android:layout_toRightOf
  • 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.

Be the first to comment

Leave a Reply

Your email address will not be published.


*