Android Relative layout

Source: Internet
Author: User

Relativelayout layout
android:layout_margintop= "25dip"//Top distance
Android:gravity= "left"//Space layout location
android:layout_marginleft= "15dip//Distance left margin


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;

Android:id---Specify the appropriate ID for the control
Android:text---The text that is displayed in the specified control, it is important to note that the string in the Strings.xml file is used as much as possible.
Android:grivity---The base position of the specified control, such as centering, right, etc. this refers to the position of the text in the control, not the control itself.
Android:textsize---The size of the font in the specified control
Android:background---Specifies the background color used by the control, and the RGB naming method
Android:width---The width of the specified control
Android:height---The height of the specified control
android:padding*---Specifies the padding for the control, meaning that the contents of the control
Android:sigleline---If set to true, the contents of the control are displayed in the same row

Below is a description of the relative layout property: Relativelayout

Android:layout_above the bottom of the control to the given ID control
Android:layout_below the top of the control to 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 the baseline of the control's baseline and the given ID of the control
Android:layout_alignbottom aligns the bottom edge of the control with the bottom edge of the given ID control
Android:layout_alignleft aligns the left edge of the control with the left edge of the given ID control
Android:layout_alignright aligns the right edge of the control with the right edge of the given ID control
Android:layout_aligntop aligns the top edge of the control with the top of the given ID control

Android:alignparentbottom if the value is true, align the bottom of the control with the bottom of the parent control
Android:layout_alignparentleft if the value is true, align the left side of the control with the left side of the parent control
Android:layout_alignparentright if the value is true, align the right side of the control with the right side of the parent control
Android:layout_alignparenttop if the value is true, aligns the top of the control with the top of the parent control

Android:layout_centerhorizontal If true, the control will be in the horizontal direction of the central
Android:layout_centerinparent If true, the control will be centered on the horizontal and vertical direction of the parent control
Android:layout_centervertical If true, the control will be in the vertical direction of the central
Android:layout_marginleft This property is used to set the gap between controls (controls and controls are different from the inside margin)
Android:padding= "3dip" indicates that the inner margin of the four edges is 3dip


Tablelayout

<tablelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:stretchcolumns= "0"
></TableLayout>

android:stretchcolumns= "0" The first column fills the entire row as an extruded column

EditText Property Description


Android:scrollhorizontally
If you set the text to exceed the width of the TextView, the horizontal pull bar appears.


The following is more clear. ----------------------------------------------------
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


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.

Transferred from: http://blog.sina.com.cn/s/blog_485c8cc50100u6cw.html

Android Relative layout

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.