Android-relativelayout Layout Tips (i)

Source: Internet
Author: User

If there is a need for this, there is a button in the top right corner of the header

1     <?XML version= "1.0" encoding= "Utf-8"?>  2     <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"  3 Android:layout_width= "Match_parent"  4 Android:layout_height= "Match_parent"  5 android:orientation= "vertical" >  6      <Relativelayout7          Android:layout_width= "Match_parent"  8 Android:layout_height= "45DP"  9 Android:background= "@color/pink_light">  Ten          <TextView One              Android:layout_width= "Wrap_content"   A Android:layout_height= "Wrap_content"   - Android:text= "title"   - android:layout_centerinparent= "true"   the              />   -             -          <Button -              Android:layout_width= "45DP"   + Android:layout_height= "26DP"   - Android:layout_alignparentright= "true"   + Android:layout_marginright= "10DP"   A android:layout_centervertical= "true"   at Android:background= "@color/green_light"   - Android:text= "More"   - android:textsize= "12SP"   -              />   -      </Relativelayout>      -     </LinearLayout>  

In fact, the above example uses the relative layout of the relative parent control, centered, right, distance to the right of how many db. Of course, relative to the parent control is more, we also give you a reference, for example, we can be relative to the title of TextView as a reference

1     <?XML version= "1.0" encoding= "Utf-8"?>  2     <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"  3 Android:layout_width= "Match_parent"  4 Android:layout_height= "Match_parent"  5 android:orientation= "vertical" >  6      <Relativelayout7          Android:layout_width= "Match_parent"  8 Android:layout_height= "45DP"  9 Android:background= "@color/pink_light">  Ten          <TextView One              Android:id= "@+id/title"   A Android:layout_width= "Wrap_content"   - Android:layout_height= "Wrap_content"   - Android:text= "title"   the android:layout_centerinparent= "true"   -              />   -          <TextView -              Android:layout_width= "Wrap_content"   + Android:layout_height= "Wrap_content"   - Android:text= "Heading 2"   + Android:layout_torightof= "@+id/title"   A android:layout_centerinparent= "true"   at Android:layout_marginleft= "5DP"   -              />   -      </Relativelayout>      -     </LinearLayout>  

This article is mainly relative reference

Android-relativelayout Layout Tips (i)

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.