Android Development Layout 1--relativelayout layout

Source: Internet
Author: User

Relativelayout Relative Layout

  True or false Property

  Layout_centerhorizontal when the control is in the middle of the parent control's horizontal position

Layout_centervertical when the control is in the vertical middle position of the parent control

Layout_centerinparent when the control is in the central location of the parent control

Layout_alignparentbotton when the lower end of the control aligns with the lower end of the parent control

Layout_alignparentleft when the left side of the control is aligned to the left of the parent control

Layout_alignparentright aligns the right side of the control to the right side of the parent control

Layout_alignparenttop when the top of the control is aligned with the top of the parent control

Layout_alignwithparentmissing referencing a parent control when the reference control does not exist or is not visible

  Property value is a property of Another control ID

Layout_torightof causes the current control to be positioned to the right of the given ID control

Layout_toleftof the current control at the left of the given ID control

Layout_above causes the current control to be positioned on the top side of the given ID control

Layout_below causes the current control to be located on the lower side of the given ID control

  Properties in pixels

Layout_marginleft left white on the current control

Layout_marginright left White on the right side of the current control

Layout_margintop white space above the current control

Layout_marginbottom the current control below the left white

**android.widget.relativelayout.layoutparams

Layoutparams is an inline class for realticelayout, and by instantiating this class, we can dynamically add view in Relativvelayout

Layoutparams has a constructor: relativelayout.layoutparams (int w, int h)

The parameter specifies the width and height of the child View, which is the same as the parent class, and the key to implementing the relative layout is on its two addRule methods.

The Addrule method has two overloaded ways

1.addRule (int verb, int anchor)

The anchor parameter specifies either the ID of the View ("relative to"), relativelayout.true (with some alignment enabled), or 1 (applied to some verb that do not require anchor), and the AddRule parameter of the verb method specifies the relative "action" (The following constants are defined in Android.widget.RelativeLayout and are not given their full names for brevity):

Align_bottom, Align_left, Align_right, Align_top: Aligns the bottom/left/right/top edges of this view with the bottom/left/right/top edges of the specified view of the anchor.

Left_of,right_of: Located on the left/right side of the View specified by anchor.

Center_horizontal, Center_in_parent, center_vertical: If Anchor is TRUE, it is centered/vertically centered in the PARENT Center/horizontal and vertical.
Position_above, Position_below, Position_to_left, position_to_right: This view is located on the top/bottom/left/right side of the view specified by anchor.

2.addRule (int verb)

Align_with_parent_bottom, Align_with_parent_left, Align_with_parent_right, Align_with_parent_top

At bottom/left/right/top of Parent view

Android Development Layout 1--relativelayout 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.