Android Project three layouts

Source: Internet
Author: User

The first thing to understand is that the Android component uses a box model, with the same margin and padding attributes as the HTML tag, but with a different name. Second, Android does not use the PX unit in the layout, but uses the DP as the length unit, the SP is the font size unit

First, linear layout linealayout

It is important to note that the linearlayout tag has a required attribute android:orientation, which indicates whether the component is horizontally expanded (horizontal) or vertically expanded (vertical). Here is a basic use of a linearlayout

1. Horizontal Expansion--horizontal

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Horizontal"><!--Horizontal Expansion -    <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_margin= "10DP"Android:background= "@color/coloraccent"Android:text= "This is Text 1!"android:textsize= "25SP"/>    <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_margin= "10DP"Android:background= "@color/colorprimary"Android:text= "This is Text 2"android:textsize= "20SP"/></LinearLayout>

Preview: You can see the second textview on the right of the first TextView

2. Expand--vertical Vertically

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"><!--verticalExpand -    <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_margin= "10DP"Android:background= "@color/coloraccent"Android:text= "This is Text 1!"android:textsize= "25SP"/>    <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_margin= "10DP"Android:background= "@color/colorprimary"Android:text= "This is Text 2"android:textsize= "20SP"/></LinearLayout>

Preview: You can see the second TextView below the first TextView

Two

Android Project three layouts

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.