. NET programmer play to Android development---(7) Relative layout relativelayout

Source: Internet
Author: User

Relative Layout relativelayoutis a more commonly used control in the Android layout that allows you to lay out layouts for various screen resolutions,Relativelayout the control property settings relative to the location.

You can set the position of the control with the parent control, and the location between the control and the control.

1. Control and parent container location properties

Android:layout_alignparentleft= "true"child controls on left side relative to parent container
Android:layout_alignparenttop= "true"child controls top edge relative to parent container
android:layout_margintop= "50DP"distance between child control and parent container top margin
Android:layout_marginbottom= "50DP"the distance between the child control and the parent container bottom margin
android:layout_marginright= "50DP"the distance from the right margin of the child control to the parent container
android:layout_marginleft= "50DP"distance between child control and parent container left margin

                                        Android:layout_centerinparent= "true"//child controls are centered in the parent container
                                      android:layout_centerhorizontal= "true"  //child controls are centered horizontally in the parent container
                                      Android:layout_centervertical= "true"   child controls are centered vertically in the parent container

The following example shows the layout relative to the parent container

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:layout_width=" match_parent "    android:layout_height=" match_parent ">    <textview        android:id= "@+id/textview1"        android:layout_width= "match_parent"        android:layout_height= "Match_ Parent "        android:text=" is easier to layout "         android:background=" #97FFFF "                  android:layout_alignparentleft=" true "relative to the parent"        android:layout_alignparenttop= "true"        android:layout_margintop= "50DP"        android:layout_ Marginbottom= "50DP"        android:layout_marginright= "50DP"            /></relativelayout>


2. Position properties between controls and controls




3. Examples of commodity listing

. NET programmer play to Android development---(7) Relative layout relativelayout

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.