The relative layout of the Android layout relativelayout

Source: Internet
Author: User

First, relativelayout (relative layout) Overview

  Relativelayout is a relative layout control that contains child controls that are arranged in a relative position between controls or as a subclass control relative to the position of the parent class container

Second, relativelayout (relative layout) properties

1. Attributes commonly used by subclass controls in Relativelayout (relative to one location of the parent container)

Android:layout_alignparentleft = "true" sub-class control relative to the current parent class container on the left (default)

Android:layout_alignparenttop = "true" sub-class control is relative to parent container on top

Android:layout_alignparentright= "true" sub-class control relative to parent container on the right side
Android:layout_alignparentbottom= "true" sub-class control relative to parent container bottom

Android:layout_margin= "20DP" subclass control distance from four sides of the parent class container

Android:layout_marginleft = "41DP" child control distance from the left side of the parent class container

Android:layout_margintop = "41DP" child control distance from top of parent container

Android:layout_marginbottom = "41DP" child control distance from the bottom of the parent class container

android:layout_marginleft = "41DP" child control distance from the left side of the parent class container

Android:layout_marginright = "41DP" sub-class control distance from the right edge of the parent class container

Android:layout_centerinparent = "true" sub-class control is centered horizontally relative to the parent container, which is vertically centered

Android:layout_centerhorizontal = "true" sub-class control is centered horizontally relative to the parent container

Android:layout_centervertical = "true" sub-class control is centered vertically relative to parent container

2. A sub-class control is positioned relative to a subclass control

Android:layout_below = "@+id/button1" The control is at the bottom of the given ID control

Android:layout_torightof = "@+id/button1" The control is on the right side of the given ID control

Android:layout_above = "@+id/button1" The control is above the given ID control

Android:layout_toleftof = "@+id/button1" The control is on the left side of the given ID control

Android:layout_alignbaseline = "@+id/button1" The contents of the control are on a line with the contents of the given ID control

Android:layout_alignbottom the bottom edge of the control is aligned with the bottom edge of the given ID control

Android:layout_alignleft the bottom edge of the control is aligned with the left edge of the given ID control

Android:layout_alignright the bottom edge of the control is aligned with the right edge of the given ID control

Android:layout_aligntop the bottom edge of the control is aligned with the top edge of the given ID control

Third , relativelayout (relative layout) Use example

   In the mall there is usually such a layout, a picture to the right of a few information

<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" >    <ImageViewAndroid:id= "@+id/imageview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentleft= "true"Android:layout_alignparenttop= "true"Android:layout_marginleft= "26DP"Android:layout_margintop= "26DP"android:src= "@drawable/ic_launcher" />    <TextViewAndroid:id= "@+id/textview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_aligntop= "@+id/imageview1"Android:layout_marginleft= "24DP"Android:layout_torightof= "@+id/imageview1"Android:text= "Dogs Ignore Buns" />    <TextViewAndroid:id= "@+id/textview2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignleft= "@+id/textview1"Android:layout_below= "@+id/textview1"Android:text= "20 Yuan" />    <TextViewAndroid:id= "@+id/textview3"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignbottom= "@+id/imageview1"Android:layout_alignleft= "@+id/textview2"Android:text= "expensive and not tasty" /></Relativelayout>

  

The relative layout of the Android layout 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.