"Go" Android layout properties detailed

Source: Internet
Author: User

Some of the important attributes that Relativelayout uses:

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/id-name "

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 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

Other property values:

    • EditText's Android:hint sets the prompt information in the input box when EditText is empty.
    • Android:gravity

This property is the qualification for the view content. For example, a button above the text. You can set the text on the left side of the view, on the right, and so on. Take button for example:

Android:gravity= "Right" is the text on the button.

    • android: layout_gravity:

This property is used to set the position of the view relative to the parent view. For example, a button in the LinearLayout, you want to put the button on the left, right and other positions can be set by this property. Take button as an example:

android:layout_gravity= "right" button on

    • Android:layout_alignparentright

This property aligns the right end of the current control with the right side of the parent control. This property value can only be true or FALSE, which is false by default.

    • Android:scaletype:

The property is a size that controls how the picture resized/moved to the ImageView.

The meaning difference of Imageview.scaletype/android:scaletype value:

Center/center:

Centered on the original size of the picture, when the picture is longer/wider than the length/width of the view, the center portion of the image is displayed

Center_crop/centercrop:

Proportionally enlarges the size of the image so that the image is long (wide) equal to or greater than the length (width) of the view

Center_inside/centerinside:

Center the contents of the picture in full, by scaling it down or the original size to make the picture long/wide equal to or less than the length/width of the view

Fit_center/fitcenter:

Enlarges/shrinks the image to the width of the view, centered on the display

Fit_end/fitend:

Enlarges/shrinks the image to the width of the view, displayed in the lower part of the view

Fit_start/fitstart:

Enlarges/shrinks the image to the width of the view, displayed in the upper part of the view

FIT_XY/FITXY:

Enlarge/Shrink image to view size display

Matrix/matrix:

Use a matrix to draw, zoom in and out to display the image dynamically.

* * To note that the Drawable folder inside the image name can not be capitalized.

"Go" Android layout properties detailed

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.