Alignment of Android Layout
1. LinearLayout (linear layout)
Provides a model for horizontal and vertical control arrangement. You can also set the weight layout parameters of the Child control to control the relatively large layout of each control.
Small.
Horizontal (vertical) vertical (horizontal)
Fill-parent: Full Screen
Wrap-content: Suitable for the control content size
Alignment gravity values:
Top: do not change the size and place it on the top of the container.
Bottom: The position is placed at the bottom of the container without changing the size.
Left: no size change. The position is placed on the left side of the container.
Right: no size changes. The position is placed on the right side of the container.
Center_vertical: The position is placed in the vertical center of the container without changing the size.
Center_horizontal: The position is placed in the center of the horizontal direction of the container without changing the size.
Center: without changing the size, the position is placed in the center of the horizontal and vertical direction of the container.
Fill_vertical: if possible, vertical extension can fill the container
Fiil_horizontal: if possible, the horizontal extension can fill up the container
Fiil: Fill the container vertically and horizontally if possible
Ii. AbsoluteLayout (coordinate layout)
The sub-element can specify the exact x/y coordinate value and display it on the screen. (0, 0) is the upper left corner. When you move down or to the right, the coordinate value is
Larger. AbsoluteLayout has no page border and allows elements to overlap with each other (although not recommended ). We generally do not recommend
AbsoluteLayout, unless you have a legitimate reason to use it, because it makes the interface code too rigid, so that it is possible on different devices
Cannot work well.
Android: layout_x = "40px"
Android: layout_y = "56px" determines the control location
3. RelativeLayout (relative layout)
Allows child elements to specify their positions relative to other elements or parent elements (by ID ). Therefore, you can align right or up or down,
Or place the two elements in the center of the screen. Elements are arranged in order. Therefore, if the first element is in the center of the screen
Other elements of this element are arranged in the center of the screen. If you use XML to specify this layout, before you define it
The associated element must be defined.
Android: layout_centerInparent: place the current control in the central horizontal and vertical part of the parent control.
Android: layout_centerHorizontal: place the current control in the central part of the parent Control
Android: layout_centerVertical: place the current control in the center of the portrait of the parent Control
Android: layout_alignParentBottom: Align the bottom of the current control with the bottom of the parent Control
Android: layout_alignParentLeft: Align the left end of the current control with the left end of the parent Control
Android: layout_alignParentRight: Align the right end of the current control with the right end of the parent Control
Android: layout_alignParentTop: Align the top of the current control with the top of the parent Control
Android: layout_alignParentBottom: Align the bottom of the current control with the bottom of the parent Control
Android: layout_above: Move the control's bottom to the control with the given ID
Android: layout_below: place the top of the control under the control with the given ID
Android: layout_toLeftOf align the right edge of the control with the left edge of the control with the given ID
Android: layout_toRightOf align the left edge of the control with the right edge of the control with the given ID
Android: layout_alignBaseline the baseline of the control is aligned with the baseline of the control with the given ID
Android: layout_alignBottom: Compares the bottom edge of the control with the bottom edge of the given ID control.
Android: layout_alignLeft: Align the left edge of the control with the given ID
Android: layout_alignRight: Align the right edge of the control with the right edge of the given ID Control
Android: layout_alignTop: aligntop
Android: layout_marginBottom/layout_marginLeft/layout_marginRight/layout_marginTop = "30px"
Leave the corresponding pixel space at the bottom/left/right/top of the Current Control
Iv. FrameLayout (single frame layout)
Is the simplest layout object. It is customized as a blank standby area on your screen, where you can then fill in a single object
-For example, a picture you want to publish. All the child elements will be fixed in the upper left corner of the screen; you cannot be a child in FrameLayout.
Element specifies a location. The next child element will overwrite the previous child element and block them in part or whole (unless
).
Android: src = "@ drawable/" attribute specifies the File Location of the image. When you use ImageView to display the image, you must also use
Android: src specifies the image to be displayed
5. TableLayout (table layout)
Manage child controls in the form of columns, each row is a TableRow object, TableRow can also add child Controls
Android: collapseColumns = "n" hides the TableRow column n in TableLayout.
Android: stretchColumns = "n": sets column n as an extended column.
Android: shrinkColumns = "n": Set column n to a column that can be shrunk.