Android Layout Properties

Source: Internet
Author: User

There are many properties in the Android layout that summarize some of the common layout properties.

First two pictures:

1.

2.

In fact, many layout properties are composed of the words in the above two graphs:

(1) There are roughly three types of layout properties for Relativelayout:

First Class: property value is True or False

Android:layout_centerhrizontal Horizontal Center
Android:layout_centervertical Vertical Center
Android:layout_centerinparent is completely centered relative to the parent element


Android:layout_alignparentbottom snaps to the bottom edge of the parent element
Android:layout_alignparentleft snaps to the left edge of the parent element
Android:layout_alignparentright snaps to the right edge of the parent element
Android:layout_alignparenttop snaps to the top edge of the parent element


android:layout_alignwithparentifmissing if the corresponding sibling element cannot be found, then the parent element is the reference.

Second Class: the attribute value must be the reference name of the id "@id/idname"

Android:layout_below at the bottom of an element
Android:layout_above at the top of an element
Android:layout_toleftof on the left side of an element
Android:layout_torightof on the right side of an element

Android:layout_aligntop aligns 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 aligns the right edge of this element with the right edge of an element

Class III: attribute values are specific pixel values, such as 100dip,100px

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

(2) common attribute tags in linearlayout

android:orientation="vertical" for vertical alignment
android:orientation="Horizontal" indicates horizontal alignment
Android:layout_width="Fill_parent" defines the width of the current view on the screen, fill_parent fills the entire screen.

  android:layout_height="wrap_content": Wraps the contents of the control. It's a bit automatic to set the width or height meaning.

Android:gravity= "Right" refers to the alignment of the child element of the element relative to it (e.g., the position of the text inside the TextView control relative to the TextView).
Android:layout_gravity= "Right" refers to the alignment of the element relative to its parent element (for example, the position of TextView relative to the parent control).

android:layout_weight= "0" weights, which are used to assign values to the importance of multiple controls in a linear layout, with a default value of zero.

 

Android Layout Properties

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.