Http://www.cnblogs.com/wisekingokok/archive/2011/08/23/2150452.html
The Android interface is made up of layouts and components, and the layout is like a frame in the building, and the components are the bricks in the building. Components are arranged according to the layout requirements, which makes up the interface that the user sees. The five major layouts for Android are linearlayout (linear layout), Framelayout (single frame layout), relativelayout (relative layout), Absolutelayout (absolute layout) and tablelayout (table layout).
LinearLayout:
LinearLayout arranges the child elements in a vertical or horizontal order, each of which is behind the previous element. If it is arranged vertically, it will be a single row of n rows of structure, each row will have only one element, regardless of the width of the element, if it is arranged horizontally, then it will be a single row n column structure. If two rows of two columns are constructed, the usual way is to arrange the two elements vertically, and each element contains a linearlayout to be arranged horizontally.
The child element attribute Android:layout_weight in LinearLayout takes effect, which is used to describe the size ratio of the child element in the remaining space. Add a row only a text box, then its default value is 0, if there are two equal-length text boxes in a row, then their android:layout_weight value can be the same as 1. If there are two unequal text boxes in a row, their android:layout_weight values are 1 and 2, respectively, then the first text box will occupy two-thirds of the remaining space, and the second text box will occupy One-third of the remaining space. Android:layout_weight follows the principle that the smaller the value, the higher the importance. The display results are as follows:
11 <?xml version= "1.0" encoding= "Utf-8"?>22 <linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation= "vertical" Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" >33 <textview android:layout_width= "fill_parent" android:layout_height= "Wrap_content" android:background= "# ff000000 "android:text=" @string/hello "/>44 <linearlayout android:orientation= "Horizontal" android:layout_width= "fill_parent" android:layout_height= "fill _parent ">55 <textview android:layout_width= "fill_parent" android:layout_height= "Wrap_content" android:background= "# ff654321 "android:layout_weight=" 1 "android:text=" 1 "/>66 <textview android:layout_width= "fill_parent" android:layout_height= "Wrap_content" android:background= "# FFFEDCBA "android:layout_weight=" 2 "android:text=" 2 "/>77 </LinearLayout>88 </LinearLayout>
View Code
Framelayout:
Framelayout is the simplest layout of the five layouts in which the entire interface is treated as a blank spare area where all the child elements cannot be placed, and they are placed in the upper left corner of the area. And the subsequent child elements are directly above the preceding child elements, partially and completely obscured by the preceding child elements. The display works as follows, the first TextView is completely obscured by the second TextView, and the third TextView obscures part of the second TextView.
1 Framelayout2<?xml version= "1.0" encoding= "Utf-8"?>3<framelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation= "Vertical" Android : layout_width= "fill_parent" android:layout_height= "Fill_parent" >4<textview android:layout_width= "fill_parent" android:layout_height= "fill_parent" android:background= "#ff000000 "android:gravity=" Center "android:text=" 1 "/>5<textview android:layout_width= "fill_parent" android:layout_height= "fill_parent" android:background= "#ff654321 "android:gravity=" center "android:text=" 2 "/>6<textview android:layout_width= "50DP" android:layout_height= "50DP" android:background= "#fffedcba" Android: gravity= "Center" android:text= "3"/>7</FrameLayout>
View Code
Absolutelayout:
Absolutelayout is an absolute position layout . The android:layout_x and Android:layout_y properties of child elements in this layout take effect and are used to describe the coordinate position of the child element. The upper-left corner of the screen is the coordinate origin (0,0), the first 0 represents the horizontal axis, the value is moved to the right, the second 0 represents the ordinate, and the value increases. Child elements in this layout can overlap each other. In real-world development, this layout is usually not used because its interface code is too rigid to be able to fit a variety of terminals well. The display results are as follows:
1 Absolutelayout2<?xml version= "1.0" encoding= "Utf-8"?>3<absolutelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation= "vertical" Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" >4<textview android:layout_width= "50DP" android:layout_height= "50DP" android:background= "#ffffffff" Android: gravity= "center" android:layout_x= "50DP" android:layout_y= "50DP" android:text= "1"/>5<textview android:layout_width= "50DP" android:layout_height= "50DP" android:background= "#ff654321" Android: gravity= "center" android:layout_x= "25DP" android:layout_y= "25DP" android:text= "2"/>6<textview android:layout_width= "50DP" android:layout_height= "50DP" android:background= "#fffedcba" Android: gravity= "center" android:layout_x= "125DP" android:layout_y= "125DP" android:text= "3"/>7</AbsoluteLayout>
View Code
On Android five layouts (i)--linearlayout, framelayout and absoultelayout "Turn"