Getting Started with Android (v) Screen components 5.5 relativelayout relative layout

Source: Internet
Author: User
Tags relative

Using Relativelayout, you can specify the location of the child view that it contains by setting the relative position (where each view is relative to another view). Look at the code in the main.xml below:

<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http://schemas.android.com/apk/res/" Android "android:id=" @+id/rlayout "android:layout_width=" fill_parent "android:layout_height=" "Fill_parent" &    
       
    Gt <textview android:id= "@+id/lblcomments" android:layout_width= "Wrap_content" android:layou 
        t_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_alignparenttop= "true" android:text= "Comments"/> <edittext android:id= "@+id/txtcomments" Android: 
        Layout_width= "Fill_parent" android:layout_height= "170px" android:layout_alignleft= "@+id/lblcomments" android:layout_below= "@+id/lblcomments" android:layout_centerhorizontal= "true" android:textsize= "1 
        8sp "/> <button android:id=" @+id/btnsave "android:layout_width=" 125px " Android:layout_height= "Wrap_content" android:layout_alignright= "@+id/txtcomments" android:layout_below= "@+id" 
        /txtcomments "android:text=" Save "/> <button android:id=" @+id/btncancel " Android:layout_width= "124px" android:layout_height= "wrap_content" android:layout_alignleft= "@+id/txtC Omments "android:layout_below=" @+id/txtcomments "android:text=" Cancel "/> </relativela Yout>

As you can see, these views are embedded in the relativelayout, and each view has some unique properties to align with the other view. These properties are:

Layout_alignparenttop

Layout_alignparentleft

Layout_alignright

Layout_below

Layout_centerhorizontal

The values of these properties are the IDs of each referenced view.

Effect Chart:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Related Article

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.