The position of the control in the relative layout needs to be determined by the relative position with the parent container (relative to the layout itself) or other adjacent controls (the relative position is here at the top, bottom, left and right of the finger of the specified control).
Common property values for relative layouts are as follows:
XML attribute description layout_height sets the layout height layout_width sets the layout width Alignment of gravity inner controls (see Table 2 for attribute values) The alignment of layout_gravity in the parent container layout (see Table 3 for attribute values) background background color or image padding internal spacing padding_left inner left space padding_right inner right padding padding_top inner top spacing padding_bottom inner bottom spacing layout_margin is the (top, bottom, left, and right) margins of the container layout layout_marginLeft with the left margin of the parent container layout_marginRight and parent container's right margin layout_marginTop and the top margin of the parent container layout_marginBottom and the bottom margin of the parent container Table 1
list of gravity property values top top alignment bottom bottom alignment left left-aligned right Align right center Centers both horizontally and vertically center_vertical Center vertically center_horizontal center horizontally center_vertical vertical fill center_horizontal horizontal fill Table 2
The alignment of this layout within the parent container - a list of layout_gravity property values
Property description layout_center_horizontal center horizontally layout_center_vertical Center vertically layout_centerInParent is centered in the parent container (ie horizontally, vertically) layout_alignParentBottom aligns the bottom in the parent container layout_alignParentTop aligns top in parent container layout_alignParentLeft aligns left in parent container layout_alignParentRight aligns right in parent container layout_alignBaseline aligns the control's baseline with the given ID's baseline table 3
That is, the effect of layout_alignBaseline can be that the bottom of the text is on a horizontal line
. For example:
android:layout_alignBaseline="@id/tvPassword" means to align the bottom of this control and @id/tvPassword control
with the attribute value list of the relative position of the adjacent control , as shown in Table 4
Property description toRightOf is to the right of the control with the specified id value toLeftOf is on the left side of the control with the specified id value above is above the control with the specified id value below is located below the control with the specified id value layout_alignTop is aligned with the top of the control with the specified id value layout_alignBottom aligns the bottom of the control with the specified id value layout_alignRight aligns the right end of the control with the specified id value layout_alignLeft aligns the left end of the control with the specified id value Table 4