The more common layouts in Android are linear layouts (linearlayout), table layouts (tablelayout), relative layouts (relativelayout), and frame layouts (framelayout).
A linear layout is one in which the components are arranged in a linear, vertical or horizontal direction, and the layout direction of the component can be controlled by the Orientation property, which has a horizontal (horizontal) and a vertical (vertical) value. After figuring out the layout, this thing on the thinking plus practice, in a variety of ways to draw on the paper, or in the mind to draw, and then write layout documents to practice, the time is naturally skilled.
1, the screen divided into 2 parts, the above part, the following part
2, the above section is divided into 4 columns
3, the following section is divided into 4 lines
OK, start practicing! (Create project test layout in Eclipse, modify main.xml files in the layout directory under its res directory)
The first step: Consider the number of linearlayout use, and determine its direction, because it is divided into the upper and lower parts, so the outermost layout using the vertical direction of the layout, inside two layout respectively indicate up and down;
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:orientation=" vertical "
android:layout_width=" fill_parent " android:layout" _height= "Fill_parent" > <LinearLayout> <!--upper part-->
</LinearLayout> <LinearLayout> <!--below part-->
</LinearLayout>
</LinearLayout>
Step Two: Add the internal layout attribute and add the component, here uses the TextView component to fill the LinearLayout, unceasingly complements the adjustment, the final layout document is as follows:
<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android= "http://" Schemas.android.com/apk/res/android " android:orientation=" vertical " android:layout_width=" Fill_ Parent " android:layout_height=" fill_parent "> <linearlayout android:orientation=" Horizontal " Android:layout_width= "fill_parent" android:layout_height= "fill_parent" android:layout_weight= " 1 "> <textview android:text=" col1 "android:gravity=" Center_horizon
Tal " android:background=" #999999 " android:layout_width=" Wrap_content " android:layout_height= "fill_parent" android:layout_weight= "1"/> <t Extview android:text= "col2" android:gravity= "Center_horizontal" Android : background= "#290fc0" android:layouT_width= "wrap_content" android:layout_height= "Fill_parent" android:layout_weight= "1
"/> <textview android:text= col3" android:gravity= "Center_horizontal" Android:background= "#999999" android:layout_width= "Wrap_content" Andro
id:layout_height= "Fill_parent" android:layout_weight= "1"/> <textview
android:text= "Col4" android:gravity= "Center_horizontal" android:background= "#290fc0" Android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" an droid:layout_weight= "1"/> </LinearLayout> <linearlayout android:orientation= "Vertica L "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "android:layout_weight = "1" > <teXtview android:text= "Row_one" android:textsize= "15sp" android:background= "#290fc 0 "android:layout_width=" fill_parent "android:layout_height=" Wrap_content "Andro id:layout_weight= "1"/> <textview android:text= "row_two" android:textsize= "15sp "Android:background=" #999999 "android:layout_width=" Fill_parent "android:layout _height= "Wrap_content" android:layout_weight= "1"/> <textview android:text= "row _three "android:textsize=" 15sp "android:background=" #290fc0 "Android:layout_widt
H= "Fill_parent" android:layout_height= "Wrap_content" android:layout_weight= "1"/> <textview android:text= "Row_four" android:textsize= "15SP" Android:background
= "#999999" Android:layout_width= "Fill_parent" android:layout_height= "Wrap_content" android:layout_weight = "1"/> </LinearLayout> </LinearLayout>
The effect is as shown in the following illustration: