Android common layout of the linear layout

Source: Internet
Author: User
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.
Practice Requirements:
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:
LinearLayout
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.