Android Learning sixth chapter (layout two--relativelayout)

Source: Internet
Author: User

Today, let's take a look at the Relativelayout layout in Android layout (relative layout)

According to the English translation comes to mean relative layout, it is easy to understand, this same layout using the elements and elements of fine-tuning to do layout

  meaning : layout by fine-tuning between elements and elements;

  Benefits: can be handled in detail

  Cons: The relationship between elements is too strong, possibly an element that changes the circumstances of other elements to occur

Let's take a look at one of the following code layout cases

<!--the first relative layout here we can set the width height to full parent element as the maximum parent element -<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.activitylife.MainActivity">    <!--the second relative layout here sets the width to full parent element height 200DP background color to blue -    <RelativelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "200DP"Android:background= "@android: Color/holo_blue_bright"></Relativelayout>    <!--the third relative layout here sets the width to full parent element height 100DP background color green -    <RelativelayoutAndroid:layout_width= "Match_parent"Android:layout_height= "100DP"Android:background= "@android: Color/holo_green_dark"></Relativelayout>        </Relativelayout>

The effect is:

  

Let's change the code.

  

<!--the first relative layout here we can set the width height to full parent element as the maximum parent element -<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.activitylife.MainActivity">    <!--the second relative layout here sets the width of the parent element height 200DP background color for blue here we added an ID of rel1 for the second relative layout -    <RelativelayoutAndroid:id= "@+id/rel1"Android:layout_width= "Match_parent"Android:layout_height= "200DP"Android:background= "@android: Color/holo_blue_bright"></Relativelayout>    <!--the third relative layout here sets the width to full parent element height 100DP background color for green here we add a property for the third relative layout day for Android:layout_below refers to when Before the element as to some element we will this element as to the bottom of the ID rel1 element -    <RelativelayoutAndroid:layout_below= "@id/rel1"Android:layout_width= "Match_parent"Android:layout_height= "100DP"Android:background= "@android: Color/holo_green_dark"></Relativelayout>        </Relativelayout>

  

  

The above is a simple introduction to the relative layout, I hope we can help

Android Learning sixth chapter (layout two--relativelayout)

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.