"Android Development-5" interface decoration, five major layouts who do you choose?

Source: Internet
Author: User

Introduction: If you want to open a shop, store decoration is very important thing. Rich are invited to design a special architectural company to decorate, no money can only their own blind toss, not good-looking all by their own feelings. Like Android development, on the mobile side you see the interface vision is not very much, the general even open the power is gone. Therefore, the development of Android has a dedicated UI designer, since the UI design diagram, how the layout needs to rely on their own choice, the five layouts can be arbitrarily selected, as long as you can achieve the effect of your UI design diagram. Design drawings to you, you choose which decoration works for you to decorate, see efficiency; Needless to say, we all choose high efficiency to decorate.


The five main layouts of Android:

1. Linear layout (LinearLayout)

2. Relative layout (relativelayout)

3. Frame Layout (framelayout)

4. Table layout (tablelayout)

5. Absolute layout (absolutelayout)


First, linear layout

First look directly at:


Then look at the code in the interface layout file:

<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <textview android:layout_width= "WR Ap_content "android:layout_height=" wrap_content "android:background=" #aa0000 "android:text=" linear layout combat--        Vertical effect "android:layout_gravity=" center "/> <textview android:layout_width=" Fill_parent " android:layout_height= "Wrap_content" android:background= "#00ff00" android:text= "linear layout combat--vertical effect" an droid:gravity= "center"/> <linearlayout android:layout_width= "Match_parent" Android:layout_ height= "fill_parent" android:orientation= "horizontal" > <textview android:layout_width= "Wrap_cont        Ent "android:layout_height=" fill_parent "android:background=" #FFC0CB "android:text=" linear layout combat-vertical effect " android:layout_gravity="Center" android:layout_weight= "1"/> <textview android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" android:background= "#b0e0e6" android:text= "linear layout combat--vertical effect" and roid:layout_gravity= "Center" android:layout_weight= "1"/> </LinearLayout></LinearLayout>

Perceptual Analysis to understand the following:

The android:orientation in LinearLayout is an important attribute in linear layout by setting two property values: Vertical and horizontal, which let you include the The child controls in the LinearLayout are laid out in a vertical or horizontal direction.


The above also useful to the layout of the commonly used properties, we also first perceptual understanding:

Android:layout_width Setting the layout width

Android:layout_height Set the layout height (these two properties, its value can be set with Match_parent, Wrap_content, Fill_parent, respectively, to match the height or width of the parent control, the height or width of the package content, Full parent control, you can see the effect in it)

Android:layout_gravity sets the position of the control, its property values are Center/right/left, etc.

Android:gravity set the content location in the control, its property values are Center/right/left, etc.

Android:background Setting the background color

Android:layout_weight set the relative proportion of the control in the LinearLayout, this need to practice the various proportions of multiple controls in order to better understand

Android:text Setting the text value of a control

Note: For linear layout, of course, can also nest a variety of layouts, the above linear layout nested linear layout, in fact, various layouts can be nested with each other, as long as there is no error on the line, practice the truth.


Second, the relative layout (very late, tomorrow night Continue)


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.