Android Learning-interface-layout-relativelayout

Source: Internet
Author: User

Relativelayout relative layout, all internal components are relative

XML properties

XML properties Function Description
Android:gravity Setgravity How the internal components are aligned
Android:ignoregravity Setignoregravity Set which component is not affected by gravity

Relativelayout.layoutparams used to set the alignment of internal components

XML properties Description
Android:layout_centerhorizontal Center horizontally
Android:layout_centervertical Center vertically
Android:layout_centerinparent Horizontal Vertical Center
Android:layout_alignparenttop Layout up, down, left, left, right
Android:layout_alignparentbottom
Android:layout_alignparentright
Android:layout_alignparentleft

Code

<Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "${relativepackage}.${activityclass}" >    <ButtonAndroid:id= "@+id/button1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_centerhorizontal= "true"Android:text= "Center Horizontally" />        <ButtonAndroid:id= "@+id/button2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centervertical= "true"Android:text= "Center Vertically" />        <ButtonAndroid:id= "@+id/button3"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_centerinparent= "true"Android:text= "Vertical Horizontal Center" />        <ButtonAndroid:id= "@+id/button4"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparenttop= "true"Android:text= "Top of layout" />        <ButtonAndroid:id= "@+id/button5"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentleft= "true"Android:layout_alignparentbottom= "true"Android:text= "layout left bottom" />        <ButtonAndroid:id= "@+id/button6"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentright= "true"Android:text= "Layout Right" />    <ButtonAndroid:id= "@+id/button7"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentbottom= "true"Android:layout_alignparentright= "true"Android:text= "layout Right Bottom" /></Relativelayout>
View Code

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.