RelativeLayouts are more complex to work with from my point of view, but they are well worth the effort. First we need to have a very clear idea of how the elements of the screen are going to be displayed.
Let's have a look at some of the most important attributes we can use in a widget to place it in a RelativeLayout.
android:layout_alignLeft = “@+id/widget”
android:layout_alignTop = “@+id/widget”
android:layout_alignBottom = “@+id/widget”
android:layout_alignRight = “@+id/widget”
Using the layout_align attribute, we are making the left/top/bottom/right edge of this view match the left/top/bottom/right edge of the given anchor view ID.
android:layout_alignParentLeft=”true|false”
android:layout_alignParentTop=”true|false”
android:layout_alignParentBottom=”true|false”
android:layout_alignParentRight=”true|false”
Using the layout_alignParent attributes, with the true or false value, we place the view at the left/top/bottom/right of its parent.
android:layout_below=”@+id/widget”
android:layout_above=”@+id/widget”
With this parameter we can place a view above or below another we specify in the value.
Hint!-> Views relationship are evaluated "in one pass", so, to assure your screen works how you want, if View A depends on view B, put B before A in the layout.