Android Relativelayout Properties Encyclopedia (Chinese explanation)

Source: Internet
Author: User

  • Relative to the given ID control

    Android:layout_above the bottom of the control to the control of the given ID;
    Android:layout_below Place the bottom of the control under the control of the given ID;
    Android:layout_toleftof aligns the right edge of the control with the left edge of the control for the given ID;
    Android:layout_torightof aligns the left edge of the control with the right edge of the control for the given ID;
    Android:layout_alignbaseline aligns the baseline of the control with the baseline of the given ID;
    Android:layout_aligntop aligns the top edge of the control with the top edge of the given ID;
    Android:layout_alignbottom aligns the bottom edge of the control with the bottom edge of the given ID;
    Android:layout_alignleft aligns the left edge of the control with the left edge of the given ID;
    Android:layout_alignright aligns the right edge of the control with the right edge of the given ID;

  • Relative to Parent component

    Android:layout_alignparenttop If true, aligns the top of the control with the top of its parent control;
    Android:layout_alignparentbottom If true, aligns the bottom of the control with the bottom of its parent control;
    Android:layout_alignparentleft If true, aligns the left part of the control with the left part of its parent control;
    Android:layout_alignparentright If true, aligns the right part of the control with the right side of its parent control;

  • Center

    Android:layout_centerhorizontal If True, the control is placed horizontally centered;
    Android:layout_centervertical If True, the control is placed vertically centered;
    Android:layout_centerinparent If True, the control is placed in the center of the parent control;

  • Specify moving pixels

    The value of the offset on the android:layout_margintop;
    Android:layout_marginbottom the value of the offset;
    Android:layout_marginleft the value of the left offset;
    Android:layout_marginright the value of the right offset;

  • Example

"@id/***""@id/***"trueandroid:layout_marginLeft = “10px”
<?xml version="1.0"encoding="Utf-8"?> <relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"Android:layout_width="Fill_parent"android:layout_height="Fill_parent"> <textview android:id="@+id/label"Android:layout_width="Fill_parent"android:layout_height="Wrap_content"android:text="Type here:"/> <edittext android:id="@+id/entry"Android:layout_width="Fill_parent"android:layout_height="Wrap_content"Android:background="@android:d rawable/editbox_background"android:layout_below="@id/label"/> <button android:id="@+id/ok"Android:layout_width="Wrap_content"android:layout_height="Wrap_content"android:layout_below="@id/entry"android:layout_alignparentright="true"android:layout_marginleft="10dip"android:text="OK"/> <button android:layout_width="Wrap_content"android:layout_height="Wrap_content"android:layout_toleftof="@id/ok"android:layout_aligntop="@id/ok"android:text="Cancel"/> </RelativeLayout>

This is a very common layout content, explained as follows:
android:layout_below= "@id/label"/>
Places the current control below the control with the ID label.
Android:layout_alignparentright= "true"
Aligns the right end of the current control with the right end of the parent control. This property value can only be true or FALSE, which is false by default.
android:layout_marginleft= "10dip"
Leave the space on the left side of the current control empty.
android:layout_toleftof= "@id/ok"
Places the current control to the left of the control with an OK ID.
android:layout_aligntop= "@id/ok"
Aligns the current control with the upper end of the ID control. At this point, we have found that the properties of the various. Here's a quick summary:

    • First Class: 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
    • Second class: The attribute value must be the reference name of the id "@id/id-name"
      *android:layout_below
      *android:layout_above
      *android:layout_toleftof
      *android:layout_torightof
      *android:layout_aligntop
    • Class III: Attribute values are specific pixel values, such as 30dip,40px
      *android:layout_marginbottom
      *android:layout_marginleft
      *android:layout_marginright
      *android:layout_margintop

Android Relativelayout Properties Encyclopedia (Chinese explanation)

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.