Thoughts on Android (14): Relative layout relativelayout

Source: Internet
Author: User

Relative layout relativelayout, inherited from viewgroup. The position of the sub-component of the relative layout is always relative to the sibling component or parent container.

XML attributes supported by Relativelayout:

android:gravity setgravity (int): Set the alignment of the subcomponents in the container

android:ignoregravity setignoregravity (int): Sets which subcomponent is not affected by the gravity Property

Relativelayout has an internal class relativelayout.layoutparams to control how the subcomponents are laid out.

The XML attributes supported by Relativelayout.layoutparams are as follows:

First Class:Property value istrueorfalse
Android:layout_centerhrizontalCenter Horizontally
Android:layout_centerverticalCenter Vertically
Android:layout_centerinparentfully centered relative to parent element
Android:layout_alignparentbottomsnaps to the bottom edge of the parent element
Android:layout_alignparentleftsnaps to the left edge of the parent element
Android:layout_alignparentrightsnaps to the right edge of the parent element
Android:layout_alignparenttopsnaps to the top edge of the parent element
Android:layout_alignwithparentifmissingif the corresponding sibling element cannot be found, then the parent element is the reference.

Class II: The attribute value must beIDthe reference name"@id/id-name”
Android:layout_belowat the bottom of an element
Android:layout_aboveat the top of an element
Android:layout_toleftofon the left side of an element
Android:layout_torightofon the right side of an element

android:layout_aligntop                        Align the top edge of this element with the top edge of an element
    android:layout_alignLeft                        Aligns the left edge of this element with the left edge of an element
    android:layout_alignBottom                   Aligns the bottom edge of this element with the bottom edge of an element
    android:layout_alignRight                      Align the right edge of this element with the right edge of an element

Class III: Attribute values are specific pixel values, such as 30dip,40px
Android:layout_marginbottom distance from the bottom edge of an element
Android:layout_marginleft distance from the left edge of an element
Android:layout_marginright distance from the right edge of an element
Android:layout_margintop distance from the top edge of an element

Android Thoughts (14): Relative 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.