Attribute |
Description |
Android: Background |
Layout background |
Android: layout_margintop |
Distance from the previous layout |
Android: gravity |
The text position in the layout, for example, center |
Android: layout_gravity |
The entire layout, such as vertical center. |
Android: layout_alignparenttop |
Whether the layout is on the top, with the left, right, and bottom |
Android: Text |
Text to be displayed in the text layout, such as textview and button |
Android: layout_aligntop = "@ ID/OK" |
Set the height of the component with the ID as OK |
Linearlayout has two very similar attributes: Android: gravity and Android: layout_gravity. The difference is that Android: gravity is used to set the alignment of the view component, while Android: layout_gravity is used to set the alignment of the container component.
For example, you can set Android: gravity = "center" to center the text in edittext in the edittext component, and set android of edittext: layout_gravity = "right" to center the edittext component in linearlayout.
Padding margin is the meaning of margins. The key issue is to understand what the margins are.
Padding is the margin of the control content relative to the control edge.
Margin is the margin of the control edge relative to the parent space.
Do you think of the difference between gravity and layout_gravity we mentioned earlier.
-
- Android: Orientation ="Vertical"Vertical Alignment
-
- Android: Orientation ="Horizontal"Horizontal Alignment
-
- Android: layout_width ="Fill_parent"Define the current view on the screen
-
- The consumable width. fill_parent fills the screen.
- Android: layout_height ="Wrap_content": Different text fields
-
- Change the width or height of the view. It means setting the box degree or height automatically.
-
-
- Layout_weight is used to assign importance values to multiple views in a linear layout.
-
- All views have a layout_weight value. The default value is 0, indicating that the value must be displayed.
-
- The size of the view occupies the size of the blank screen. If a value greater than zero is assigned, the parent
-
- The available space in the image is separated. The split size depends on the layout_weight of each view.
- Value and the overall layout_weight value of the value in the current screen layout and
-
- The percentage of the layout_weight value is determined.
-
- For example, we have a text label and two text editing elements in the horizontal direction.
-
- The text label does not specify the layout_weight value, so it occupies the minimum space required.
-
- If the layout_weight value of each of the two text editing elements is set1, The two are equally divided.
-
- The remaining width of the layout in the parent view (because we declare that the importance of the two is equal ). If two
-
- The first value of layout_weight in the text editing element is set1And the second one is2,
- Then 2/3 of the remaining space is allocated to the first space, and 1/3 to the second Space (the smaller the value, the more important
-
- Higher Degree ).