1, LinearLayout
The default orientation is horizontal
Note the relationship between android:orientation= "horizontal" and android:layout_gravity= "" in Match_parent or wrap_content
Layout_gravity operation is the layout of the component gravity= "right" is the component's contents
2, Relativelayout
Child controls are independent of each other and are left-aligned by default
Android:layout_centerhorizontal= "true"
Android:layout_centervertical= "true"
Android:layout_centerinparent= "true"
Android:layout_alignparentleft= "true"
android:layout_toleftof= "@id/center"
android:layout_below= "@id/center"
3, Framelayout
Because there is no direction, so android:layout_gravity= "bottom" up or down can be effective
Note: Framelayout must be used in Tabhost
4, Tablelayout
Tablelayout in android:stretchcolumns= "1": Specify which column stretches to fill the remaining space
The columns in the Tablelayout are aligned by default
TableRow represents a row, and several child nodes represent a few columns
The immediate child nodes of the tablelayout default layout_width= "Match_parent" and layout_height= "wrap_content" and cannot be modified
The immediate child nodes of the TableRow default layout_height= "Wrap_content" and Layout_width= "wrap_content" and cannot be modified
layout_column= "1" sets the current component to the first column
layout_span= "2" current column occupies two columns of space
5, Absolutelayout Absolute layout
Layout_x and Layout_y Specify where the space is located
When you do not need to do a screen fit for a platform or a device, you may use
Demo
<tablelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Android:stret chcolumns= "1" tools:context= ". Mainactivity "> <TableRow> <textview android:layout_column=" 1 "android:text=" O Pen "/> <textview android:gravity=" right "android:text=" Ctrl-c "/> </tablerow& Gt <TableRow> <textview android:layout_column= "1" android:text= "Save"/> < TextView android:gravity= "Right" android:text= "Ctrl."/> </TableRow> <TableRow> <textview android:layout_column= "1" android:text= "Save as:"/> <textview Android:gravity= "Right" android:text= "Ctrl-shift"/> </TableRow> <textview an Droid:layout_height= "1DP" android:background= "#000000"/> <TableRow> <textview android:text= "X"/> <textview android:layout_span= "2" android:text= "import"/> </TableRow> < ; tablerow> <textview android:text= "X"/> <textview android:text= "Export"/> <textvie W android:gravity= "right" android:text= "Ctrl"/> </TableRow> <textview Android oid:layout_height= "1DP" android:background= "#000000"/> <TableRow> <textview Andro id:layout_column= "1" android:text= "Qut"/> </TableRow></TableLayout>
Effect:
5 Layouts in Android