Layout has a great effect on the rapid construction of the interface and the adaptability of the interface to different resolution screens. Here's a brief introduction to Android's layout and research.
The realization of it.
Android has layout:framelayout,linearlayout,tablelayout,relativelayout,absolutelayout.
The XML attribute of the view that is placed in the layout:
XML attributes common to item in several layout:
(1) Layout_width
(2) Layout_height
Note: (1) and (2) are used to determine the width and height of the view that is placed in the layout: their possible values are fill_parent,wrap_content or fixed pixel values.
(3) Layout_marginleft--->paddingleft
(4) Layout_margintop--->paddingtop
(5) Layout_marginright--->paddingright
(6) Layout_marginbottom--->paddingbottom
(complement) Layout_margin--->padding
Note: (3) (4) (5) (6) is placed in the layout view and expects it to be able to distance itself from the layout boundary or other view.
(7) Layout_gravity
Note: (7) used to determine the docking position of the view in layout.
Framelayout are the simplest layout and have only these properties.
LinearLayout will also have:
(8) Layout_weight
Note: (8) The remaining space after all the child view configurations in the LinearLayout is assigned to the view that owns the property according to their layout_weight.
The Tablelayout row TableRow is a horizontal (horizontal) LinearLayout
Relativelayout has 16 align-related XML attributes:
(9) Layout_alignparentbottom The lower end of the current control with the low-end alignment of the parent control (coincident)
(Ten) Layout_alignparentleft the current control left to the left of the parent control (coincident)
(one) Layout_alignparentright the right end of the current control to the right end of the parent control (coincident)
(Layout_alignparenttop ) The top of the current control is aligned with the upper end of the parent control (coincident)
(Layout_centerhorizontal ) The current control is in the horizontal middle position of the parent control (in the middle of the horizontal direction)
(layout_centerinparent) The current control is in the middle and horizontal position of the parent control (in the middle of the vertical direction)
(layout_centervertical ) The current control is in the vertical middle position of the parent control (in the middle of the plane)
(Layout_above) causes the current control to be positioned above the given ID control
(Layout_below) causes the current control to be located below the given ID control
(layout_toleftof) to leave the current control at the left of the given ID control
(layout_torightof) causes the current control to be positioned to the right of the given ID control
(Layout_alignbottom ) causes the current control to coincide with the bottom portion of the given ID control (note that the ID control is available and aligned)
layout_alignleft causes the current control to coincide with the left of the given ID control
(layout_alignright) causes the current control to coincide with the right hand of the given ID control
(layout_aligntop) causes the current control to coincide with the top of the given ID control
(Layout_alignbaseline) The baseline of the current control is coincident with the baseline that gives the ID control T, which is used primarily for label or other widgets containing text.
Note: (9) to (24) is used to determine the position of view in the Relativelayout relative to the layout or other view in layout.
According to the Android documentation, Android will traverse the tree of layou and view nesting 2 times, one measure call to determine the size of the layout or view; Used to determine the position of a layout or view. Of course later my own cottage implementation combined these 2 calls together. That is, layout the measure once before the arrangement, and then calls the layout method on the view recursion. The size of such a child must be determined. Then use the gravity or align attribute to locate the determined size and use margin to adjust the position.
Add:
The difference between 1.android:paddingleft and Android:layout_marginleft:
padding margin is the meaning of the margin, the key question is to understand what the relative margin.
padding is the margin of the control's content relative to the edge of the control.
Layout_margin is the margin of the control's edge relative to the parent space.
2.android Gravity and layout_gravity difference
The android:gravity property is a qualification to the view content. such as a button above the text. You can set the text in view on the left, right and so on. This is the property that did this.
android:layout_gravity is used to set the view relative to the location of the parent view. For example, a button in the LinearLayout, you want to put the button on the left and right side of the position can be set through this property.
This explains, what we get the most out of the layout, and then inside a few layout, if you want to make these several layouts are bottom, you can in the most external layout of the property set androi:gravity= "Botton" because gravity is the contents of the function.
This is the Android Layout XML attributes of the collation, the follow-up will continue to add, thank you for your support.