Layout overview and RelativeLayout layout

Layout overview

1. Overview
Android provides six layout methods for application development, namely:
1. RelativeLayout
2. LinearLayout
3. TableLayout
4. FrameLayout
5. GridLayout
6. AbsolateLayout Absolute Layout


Note: The so-called parent container refers to the above controls. If there are no controls on it, the parent container represents the top of the terminal screen.

Second, the relative layout label
relative to the position of the controls in the layout needs to pass through the parent container ( The relative layout itself) or the relative position of other adjacent controls (the relative position here is located at the top, bottom, left and right of the specified control) to determine.
    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_margin_left is the left margin of the parent container
layout_margin_right is the right margin of the parent container
layout_margin_top and the top margin of the parent container
layout_margin_bottom 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 attribute 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

 





Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326837788&siteId=291194637