Android layout is an important part of application interface development. In Android, there are five layout Methods: FrameLayout (Framework layout), LinearLayout (linear layout), and AbsoluteLayout (absolute layout ), relativeLayout (relative layout), TableLayout (table layout ).
1. FrameLayout
This layout can be seen as a heap of the wall. There is a wall foot in the upper left corner of the rectangular square. We put the first thing, and we want to put another one, which is placed on the top of the original place, in this way, it will cover the original things. This layout is relatively simple, and you can only put something simple.
2. LinearLayout
Linear layout, which can be understood as a div from the external frame. First, it is listed one by one on the screen. Each LinearLayout can be divided into vertical layout android: orientation = "vertical") and horizontal layout android: orientation = "horizontal "). In vertical layout, each row has only one element, and multiple elements are vertical down in sequence. in horizontal layout, there is only one row, and each element is arranged to the right in sequence.
LinearLayout has an important attribute android: layout_weight = "1". In vertical layout, this weight represents the line spacing; in horizontal layout, it represents the column width; the larger the weight value, the larger the value.
Iii. AbsoluteLayout
The absolute layout is similar to that where div specifies the absolute attribute and uses the X and Y coordinates to specify the element location. android: layout_x = "20px" android: layout_y = "12px" is also relatively simple, however, when you switch vertically, problems often occur, and when there are multiple elements, the computation is troublesome.
Iv. RelativeLayout
The relative layout can be understood as the layout method for positioning an element as a reference object. Main attributes include:
Relative to an element
Android: layout_below = "@ id/aaa". The element is under aaa.
Android: layout_toLeftOf = "@ id/bbb". The left side of the element is bbb.
Relative to the parent Element
Android: layout_alignParentLeft = "true" align left of the parent Element
Android: layout_alignParentRight = "true" align to the right of the parent Element
You can also specify margins. For details, see API
5. TableLayout
The Table layout is similar to the Table in Html. Each TableLayout contains the table row TableRow, which can define each element and set its alignment mode android: gravity = "".
Each layout has its own method. In addition, these five layout elements can be nested with each other to create a beautiful interface.