[Android] Chapter 2 (2)-common public attributes of layout controls, Chapter 2 of android
Category: C #, Android, VS2015;
Created on:
I. Introduction
The layout controls in Android applications are container controls used to control the arrangement and placement of child elements. The layout controls provided by Android include:
- LinearLayout: Linear layout.
- GridLayout: grid layout.
- TableLayout: table layout.
- FrameLayout: Framework layout.
- Relative Layout: Relative Layout.
- AbsoluteLayout: absolute layout.
2. Common public attributes
Each layout control (layout) in Android is a container element that can be used to combine multiple child elements. Some basic attributes are common. Common basic attributes include:
1. id
Android: id: "@ + id/id1" indicates that this id is newly added and its name is id1.
"@ Id/id1" indicates that this id references the id1 control.
2. padding
Android: padding.
3. fill_parent and match_parent
Android: fill_parent or match_parent: indicates that the width (or height) is the same as that of the parent element.
4. wrap_content
Android: wrap_content: indicates that the width (or height) is automatically adjusted with the content. You can also directly use the px value to set the width or height (related to the pixel density), or use dp to set the width or height (not related to the pixel density ).
5. layout_weight
Android: layout_weight: the importance of filling the remaining space on the screen (also called priority or weight ). The default value is 0 (highest). The higher the value, the lower the priority. The priority takes effect only when the corresponding layout_width/layout_height = "fill_parent" of the parent layer; otherwise, wrap_content will be compressed to occupy only the minimum available space.
6. layout_gravity and gravity
Android: layout_gravity: Alignment of the control in its container control. That is, to which side is sunk (gravity: gravity ).
Android: gravity: Alignment of the text in the control (to which end the text is sunk ).