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)