Layout manager, java layout manager
1. Linear layout: (LinearLayout)
(1) its child elements are laid out in a linear (horizontal or vertical) manner.
(2) common attributes:
Attribute |
Description |
Android: orientation |
Control Arrangement in layout. The attribute value is horizontal (horizontal) or vertical (vertical) |
Android: gravity |
Define the container location in the control |
Android: weight |
Its Sub-controls account for the proportion. We recommend that you set layout_width to 0dp when using it. In this case, we can understand that weight is the proportion. |
(3) The gravity attribute of LinearLayout is special. Because the control is linear, gravity does not work in the layout direction. For example, when horizontal is used,
Gravity = "right" is invalid.
(4) android: Multiple Attribute values in the gravity attribute are separated by vertical bars, but there must be no spaces before or after the vertical bars.
2.
2. Table layout: (TableLayout)
(1) The elements in TableLayout are displayed in the table as rows and columns. Table row needs
Custom, the column is automatically determined by Android, and each control is a column.
(2) common attributes:
Attribute |
Description |
Android: layout_span |
Set whether the table columns are cross-Column |
Android: collapseColumns |
Set whether to hide table columns |
Android: stretchColumns |
Sets whether the columns in the table are stretched. This setting takes effect when the content is smaller than that displayed on the screen. |
Android: shrinkColumns |
Set whether to shrink the table columns. This setting takes effect when the content exceeds the screen display. |
3. Frame layout: (FrameLayout)
(1) It is usually used to occupy a blank area on the screen to display a single object. All child elements are stacked in the upper left corner of the blank area. When multiple child elements are defined, the defined elements will directly overwrite the previous one.
4. Relative layout: (RelativeLayout)
(1) is the most commonly used and flexible layout. Set the widget to set its own location relative to the location of other controls in the container or container.
(2) common attributes
Attribute |
Description |
Android: layout_abve |
Set this control to the top of the specified control. The property value is the id of the specified control. |
Android: layout_below |
Set this control to the lower of the specified control. The property value is the id of the specified control. |
Android: layout_toLeftOf |
Set this control to the left of the specified control. The property value is the id of the specified control. |
Android: layout_toRightOf |
Set this control to the right of the specified control. The property value is the id of the specified control. |
Android: layout_alignTop |
Set this control to the top of the specified control. The property value is the id of the specified control. |
Android: layout_alignLeft |
Set this control to the left of the specified control. The property value is the id of the specified control. |
Android: layout_alignRight |
Set this control to the right of the specified control. The property value is the id of the specified control. |
Android: layout_alignBottom |
Set this control to the lower of the specified control. The property value is the id of the specified control. |
Android: layout_centerHorizontal |
Sets the horizontal center of the control in the parent control. The property value is true or false. |
Android: layout_alignParentLeft |
Set the left side of the control and the parent control. The property value is true or false. |
Android: layout_alignParentRight |
Set this control to the right of the parent control. The property value is true or false. |
Android: layout_alignParentTop |
Set this control to the parent control. The property value is true or false. |
Android: layout_centerVertical |
Sets the vertical center of the control in the parent control. The property value is true or false. |
Android: layout_centerInParent |
Set the control to center in the parent control. The property value is true or false. |
Android: layout_alignParentBottom |
Set the base side of the current control and the parent control. The attribute value is true or false. |