RelativeLayout
declare class RelativeLayout extends ViewGroup {}
A Layout where the positions of the children can be described in relation to each other or to the parent.
Attribute
gravity
<RelativeLayout gravity="center">
...
</RelativeLayout>
Description
Specifies how an object should position its content, on both the X and Y axes, within its own bounds.center_vertical
center_horizontal
none
top
bottom
left
right
center
fill
fill_vertical
fill_horizontal
axis_clip
clip_vertical
clip_horizontal
ignoreGravity
<RelativeLayout ignoreGravity="center">
...
</RelativeLayout>
Description
Indicates what view should not be affected by gravity.
RelativeLayout.LayoutParams
A Layout where the positions of the children can be described in relation to each other or to the parent.
declare class LayoutParams extends RelativeLayout.MarginLayoutParams {}
Attribute
layout_above
<RelativeLayout>
<View layout_above="@id/view"/>
</RelativeLayout>
Description
Positions the bottom edge of this view above the given anchor view ID.@id/name
layout_alignBaseline
<RelativeLayout>
<View layout_alignBaseline="@id/view"/>
</RelativeLayout>
Description
Positions the baseline of this view on the baseline of the given anchor view ID.
layout_alignBottom
<RelativeLayout>
<View layout_alignBottom="@id/view"/>
</RelativeLayout>
Description
Makes the bottom edge of this view match the bottom edge of the given anchor view ID.
layout_alignEnd
<RelativeLayout>
<View layout_alignEnd="@id/view"/>
</RelativeLayout>
Description
Makes the end edge of this view match the end edge of the given anchor view ID.
layout_alignLeft
<RelativeLayout>
<View layout_alignLeft="@id/view"/>
</RelativeLayout>
Description
Makes the left edge of this view match the left edge of the given anchor view ID.
layout_alignParentBottom
<RelativeLayout>
<View layout_alignParentBottom="false"/>
</RelativeLayout>
Description
If true, makes the bottom edge of this view match the bottom edge of the parent.
layout_alignParentEnd
<RelativeLayout>
<View layout_alignParentBottom="false"/>
</RelativeLayout>
Description
If true, makes the bottom edge of this view match the bottom edge of the parent.
layout_alignParentLeft
<RelativeLayout>
<View layout_alignParentLeft="false"/>
</RelativeLayout>
Description
If true, makes the left edge of this view match the left edge of the parent.
layout_alignParentRight
<RelativeLayout>
<View layout_alignParentRight="false"/>
</RelativeLayout>
Description
If true, makes the right edge of this view match the right edge of the parent.
layout_alignParentStart
<RelativeLayout>
<View layout_alignParentStart="false"/>
</RelativeLayout>
Description
If true, makes the start edge of this view match the start edge of the parent.
layout_alignParentTop
<RelativeLayout>
<View layout_alignParentTop="false"/>
</RelativeLayout>
Description
If true, makes the top edge of this view match the top edge of the parent.
layout_alignRight
<RelativeLayout>
<View layout_alignRight="@id/view"/>
</RelativeLayout>
Description
Makes the right edge of this view match the right edge of the given anchor view ID.
layout_alignStart
<RelativeLayout>
<View layout_alignStart="@id/view"/>
</RelativeLayout>
Description
Makes the start edge of this view match the start edge of the given anchor view ID.
layout_alignTop
<RelativeLayout>
<View layout_alignTop="@id/view"/>
</RelativeLayout>
Description
Makes the top edge of this view match the top edge of the given anchor view ID.
layout_alignWithParentIfMissing
<RelativeLayout>
<View layout_alignWithParentIfMissing="false"/>
</RelativeLayout>
Description
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.
layout_below
<RelativeLayout>
<View layout_below="@id/view"/>
</RelativeLayout>
Description
Positions the top edge of this view below the given anchor view ID.
layout_centerHorizontal
<RelativeLayout>
<View layout_centerHorizontal="false"/>
</RelativeLayout>
Description
If true, centers this child horizontally within its parent.
layout_centerInParent
<RelativeLayout>
<View layout_centerInParent="false"/>
</RelativeLayout>
Description
If true, centers this child horizontally and vertically within its parent.
layout_centerVertical
<RelativeLayout>
<View layout_centerVertical="false"/>
</RelativeLayout>
Description
If true, centers this child vertically within its parent.
layout_toEndOf
<RelativeLayout>
<View layout_toEndOf="@id/view"/>
</RelativeLayout>
Description
Positions the start edge of this view to the end of the given anchor view ID.
layout_toLeftOf
<RelativeLayout>
<View layout_toLeftOf="@id/view"/>
</RelativeLayout>
Description
Positions the right edge of this view to the left of the given anchor view ID.
layout_toRightOf
<RelativeLayout>
<View layout_toRightOf="@id/view"/>
</RelativeLayout>
Description
Positions the left edge of this view to the right of the given anchor view ID.
layout_toStartOf
<RelativeLayout>
<View layout_toStartOf="@id/view"/>
</RelativeLayout>
Description
Positions the end edge of this view to the start of the given anchor view ID.
When using relative positioning and sibling positioning, make sure the sibling View is in front