Android Development layouts:. XML page Layout
1. Linear layout (LinearLayout)
LinearLayout is a linear, non-layout control that contains child controls that are arranged in a horizontal or vertical manner
Android:orientation = "vertical"
---This property determines how his child controls are arranged (vertical: vertical; horizontal: Horizontal)
android:gravity = "Center"
---This property determines the location of his subclass XY
Android:layout_gravity represents the position of the component itself in the parent component
Android:gravity represents the position of the subassembly's subcomponents in the component
2. Relative layout (relativelayout)
Relativelayout is a relative layout control that contains the relative position of a child control relative to a control, or the position of a child-class control in relation to the parent container.
Way of arranging
Android:layout_alignparentleft = "true" sub-class control relative to the current parent class container on the left
Android:layout_margintop = "41DP" child controls the distance from the top of the parent class container
Android:layout_centerinparent = "true" sub-class control is centered horizontally and vertically relative to the parent class container
Android:layout_centerhorizontal = "true" sub-class controls are centered horizontally relative to the parent class container
Android:layout_centervertical = "true" sub-class controls are centered vertically relative to the parent class container
Android:layout_torightof= "@+id/1" The control is located on the right side of control 1
Android:layout_alignbottom= "@+id/1" the bottom of the control is aligned to the control 1
3. Table layout (tablelayout)
The Tablelayout table layout model manages child controls in the form of rows and columns, each of which behaves as a TableRow object, or it can be a view object.
① If we add components directly to the tablelayout, then this component will take up a line!!!
② if we want to have multiple components on one line, we need to add a TableRow container and throw the components inside!
Note that a column can represent both contraction and stretching, which can be replaced by "*" instead of shrinking or stretching all the columns, and the column numbers for these three properties are calculated starting from 0.
Android:collapsecolumns = "Up" hides the index column starting at 0. Columns must be separated by commas: 1,2,5
Android:shrinkcolumns= "Up" shrinks the index column starting at 0. When the Lietaikuan () content is too large, do not extrude the screen,
Android:stretchcolumns = "Up" stretches the index starting at 0. To fill the rest of the extra empty space. Columns must be separated by commas.
For controls within <TableRow></TableRow>
Android:layout_column = "1" indicates that the control is displayed in the 2nd column
Android:layout_span = "2" indicates that the control occupies 2 columns
4. Frame Layout (framelayout)
In this layout, none of the elements can be placed anywhere, they are placed in the upper-left corner of the area, and the subsequent child elements are directly overlaid on the preceding child elements.
Masks the preceding child elements partially and completely.
The properties of Framelayout are rarely two, but before we say it, we introduce one thing:
Foreground Image: Always at the top of the frame layout, directly facing the user's image, is not overwritten by the picture.
Two properties:
android:foreground:* setting the foreground image of a frame-changing layout container
Android:foregroundgravity: Setting the location of the foreground image display
5. Grid layout (GridLayout)
The layout is a new layout after Android 4.0, the layout of the window control in the form of a grid
One thing to say here is that the grid layout differs from other layouts in that you can set Layout_width and Layout_height properties for components
Because the width of the component is determined by a few rows of columns, you can also write a wrap_content
Common Properties:
Arrange alignment:
① set the arrangement of components: android:orientation= "" Vertical (vertical, default) or horizontal (horizontal)
② to set the alignment of the component: android:layout_gravity= "" Center,left,right,buttom Ah, these, if you want to use both kinds of words: eg:buttom|left
Set the layout to a few rows of columns:
① How many lines are set: android:rowcount= "4"//Set Grid layout with 4 rows
② How many columns are set: android:columncount= "4"//Set Grid layout with 4 columns
Set a component in a few rows of columns
Note: It's all counted from 0!
① component in the first line: Android:layout_row = "1"//Set component on the second row
② components in the number of columns: Android:layout_column = "2"//Set the component in the third column
Set a component across several rows of columns:
① across several lines: Android:layout_rowspan = "2"//vertically across 2 rows
② across several columns: Android:layout_columnspan = "3"//Cross across 2 columns
6. Absolute layout (absolutelayout)
This layout can also be called a coordinate layout, and you can directly specify the absolute position of the child element (x, y)
However, due to the large differences in the size of mobile phone screen, the use of absolute positioning will be poor, the adaptation of the screen is defective
android:layout_x = "32dip" controls the x position of the current sub-class control
android:layout_y = "32dip" controls the y position of the current sub-class control
Introduction to Android six layouts