Android Layout Properties

Source: Internet
Author: User

linearlayout layout : Linear layout configuration, in which all components are queued from top to bottom.
In this interface, we apply a linearlayout layout, which is vertically scaled down, so create a layout XML file to

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"  Android:orientation="vertical"  android:layout_width="  Fill_parent"  android:layout_height="fill_parent" >

Node as the beginning. A layout container can include 0 or more layout containers.
Explain the tags in linearlayout:

(1) android:orientation="vertical" indicates vertical alignment
(2) android:orientation="Horizontal" indicates horizontal alignment
(3) android:layout_width="Fill_parent" defines the width that the current view can consume on the screen, and fill_parent fills the entire screen.

(4) android:layout_height="wrap_content": Change the width or height of the view as the text field is different. A bit of automatic setting of the box or height meaning
The Layout_weight default value is zero, which is used to assign values to the importance of many views in a linear layout. For example, we have a text label in the horizontal direction and two text editing elements, the text label does not specify the Layout_weight value, so it will occupy the minimum space needed to provide, if two text editing elements each layout_weight value is set to 1, The two halves are evenly spaced in the remaining width of the parent view layout (because we declare that the two are of equal importance). If the layout_weight value of the first of the two text-editing elements is set to 1, and the second is set to 2, then One-third of the remaining space is given to the second, and two-thirds points to the first (proportional division). ( valid only in Linearlayou ).

relativelayout layout: allows child elements to specify their location relative to other elements or parent elements (specified by ID).

Some of the important attributes that relativelayout uses:

First Class: Property value is True or false only valid in Relativelayout

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    
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" only valid in Relativelayout

Android:layout_below below 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 the   top edge of this element and the top edge of an element align     android: Layout_alignleft aligns the left edge of  this element with the left edge of an element     android:layout_alignbottom the bottom edge of this element and the bottom edge of an element     Android:layout _alignright  

Class III: Attribute values are specific pixel values, such as 30dip,40px ( any layout is valid)

    Android:layout_marginbottom              distance from the bottom edge of an element     Android:layout_marginleft                   The distance from the left edge of an element     Android:layout _marginright                 distance from the right edge of an element     Android:layout_margintop                   

Framelayout is the simplest layout object : A frame layout style that can be loaded with an include tag into another defined layout file, and all child elements will be pinned to the upper left corner of the screen ; You cannot specify a location for a child element in the framelayout. The latter child element will overwrite the padding directly above the previous child element, blocking them partially or completely (unless the latter element is transparent).

EditText's Android:hint

Sets the prompt information in the input box when EditText is empty.

android:gravity
The Android:gravity 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 the button as an example, android:gravity= "right" then the text on the button

android:layout_gravity
Android:layout_gravity 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 For example, android:layout_gravity= "right" button on

Android:layout_alignparentright

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:scaletype:
Android:scaletype is a size that controls how the picture resized/moved to the ImageView. The meaning difference of Imageview.scaletype/android:scaletype value:

Center/center is centered on the original size of the image, and 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 Displays 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 enlarge/Shrink the picture to the width of the view, centered on the display

Fit_end/fitend Zoom in/out to the width of the view, displayed in the lower part of the view

Fit_start/fitstart enlarge/Shrink the image to the width of the view, displayed in the upper part of the view

Fit_xy/fitxy The picture is not scaled up/down to the view size display

The Matrix/matrix is drawn with a matrix and is displayed by zooming in and out of the image.

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

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.