Android RelativeLayout attributes (Chinese explanation)

Source: Internet
Author: User

Android RelativeLayout attributes (Chinese explanation)

Relative to the given ID Control

Android: layout_above: place the bottom of the control on the control with the given ID;
Android: layout_below: place the bottom of the control under the control with the given ID;
Android: layout_toLeftOf align the right edge of the control with the left edge of the control with the given ID;
Android: layout_toRightOf align the left edge of the control with the right edge of the control with the given ID;
Android: layout_alignBaseline: Align the baseline of the control with the baseline of the given ID;
Android: layout_alignTop: Align the top edge of the control with the top edge of the given ID;
Android: layout_alignBottom: Align the bottom edge of the control with the bottom edge of the given ID;
Android: layout_alignLeft: Align the left edge of the control with the left edge of the given ID;
Android: layout_alignRight: Align the right edge of the control with the right edge of the given ID;

Relative to the parent component

Android: layout_alignParentTop if it is true, align the top of the control with the top of its parent control;
Android: layout_alignParentBottom: If this parameter is set to true, the bottom of the control is aligned with the bottom of its parent control;
Android: layout_alignParentLeft: if it is true, align the left of the control with the left of its parent control;
Android: layout_alignParentRight: if it is set to true, align the right of the control with the right of its parent control;

Center

Android: layout_centerHorizontal if true, place the control horizontally in the center;
Android: layout_centerVertical if true, place the control vertically in the center;
Android: layout_centerInParent if true, place the control in the center of the parent control;

Move Pixel

Android: layout_marginTop offset value;
Android: layout_marginBottom offset value;
Android: layout_marginLeft value of the left offset;
Android: value of the right offset of layout_marginRight;

Example

android:layout_below = "@id/***"android:layout_alignBaseline = "@id/***"android:layout_alignParentTop = trueandroid:layout_marginLeft = “10px”

   
   
    
    
     
    
   
   

This is a common layout, which is explained as follows:
Android: layout_below = "@ id/label"/>
Place the current control under the control whose id is label.
Android: layout_alignParentRight = "true"
Align the right end of the current control with the right end of the parent control. The attribute value can only be true or false. The default value is false.
Android: layout_marginLeft = "10dip"
Empty space on the left of the current control.
Android: layout_toLeftOf = "@ id/OK"
Place the current control on the left of the control whose id is OK.
Android: layout_alignTop = "@ id/OK"
Align the upper end of the current control with the id control. So far, we have found that there are many attributes. Below is a brief summary:

Class 1: the property value is true or false.
* Android: layout_centerHrizontal
* Android: layout_centerVertical
* Android: layout_centerInparent
* Android: layout_alignParentBottom
* Android: layout_alignParentLeft
* Android: layout_alignParentRight
* Android: layout_alignParentTop
* Android: layout_alignWithParentIfMissing Class 2: The attribute value must be the reference name "@ id/id-name" of the id"
* Android: layout_below
* Android: layout_abve
* Android: layout_toLeftOf
* Android: layout_toRightOf
* Android: layout_alignTop Category 3: The attribute value is a specific pixel value, such as 30dip and 40px.
* Android: layout_marginBottom
* Android: layout_marginLeft
* Android: layout_marginRight
* Android: layout_marginTop

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.