Relativelayout & framelayout & absolutelayout in Android layout manager

Source: Internet
Author: User

3 relativelayout

The position of the Child control is determined by the relative position of the sibling control or parent control. The position of viewa is determined relative to viewb. Make sure that B appears before.

Attribute name Attribute description
Android: layout_centerhorizontal The current widget is located in the middle of the parent widget
Android: layout_centervertical The current control is located in the vertical middle of the parent Control
Android: layout_centerparent The current control is located in the middle of the parent control's vertical direction.
Android: layout_alignparentbottom Low-end alignment of the current control and the low-end alignment of the parent Control
Android: layout_alignparentleft Align the left side of the current control with the left side of the parent Control
Android: layout_alignparentright Align the right of the current control with the right of the parent Control
Android: layout_alignparenttop The upper end of the current control is aligned with the upper end of the parent control.
Android: layout_alignwithparentifmissing When the reference control does not exist or is invisible, refer to the parent Control
   
Android: layout_torightof Place the current control on the right of the ID Control
Android: layout_toleftof  
Android: layout_abve  
Android: layout_below  
Android: layout_aligntop  
Android: layout_alignbottom  
Android: layout_alignleft  
Android: layout_alignright  
   
Android: layout_marginleft White on the left of the Current Control
Android: layout_marginright  
Android: layout_margintop  
Android: layout_marginbottom  

Relavitelayout. xml

<? XML version = "1.0" encoding = "UTF-8"?>
<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent">
<Imageview Android: Id = "@ + ID/iv01" Android: Background = "@ drawable/img01"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: layout_centerhorizontal = "true"/>
<Imageview Android: Id = "@ + ID/iv02" Android: Background = "@ drawable/img02"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: layout_torightof = "@ ID/iv01" Android: layout_aligntop = "@ ID/iv01"/>
<Imageview Android: Id = "@ + ID/IV03" Android: Background = "@ drawable/img03"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: layout_below = "@ ID/iv01" Android: layout_alignleft = "@ ID/iv01"/>
</Relativelayout>

4 framelayout

In framelayout, child controls are drawn through stacks, and all the child controls added later are drawn on the upper layer.

Attribute name Method Description
Android: foreground Setforeground (drawable) Set to draw on all controls
Android: foregroundgravity Setforegroundgravity (INT) Set the gravity attribute of the content drawn on all child Controls

<? XML version = "1.0" encoding = "UTF-8"?>
<Framelayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent" Android: layout_height = "match_parent">
<Textview Android: Id = "@ + ID/big" Android: text = "big" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: textsize = "60px"
Android: textcolor = "@ drawable/White"/>
<Textview Android: text = "medium" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: textsize = "40px"
Android: textcolor = "@ drawable/darkgray"/>
<Textview Android: text = "small" Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" Android: textsize = "20px"
Android: textcolor = "@ drawable/ABC"/>
</Framelayout>

5 absolutelayout

<? XML version = "1.0" encoding = "UTF-8"?>
<Absolutelayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent" Android: layout_height = "match_parent">
<Imageview Android: layout_height = "wrap_content" Android: src = "@ drawable/img01"
Android: Id = "@ + ID/imageview1" Android: layout_width = "wrap_content"
Android: layout_x = "57dip" Android: layout_y = "41dip"> </imageview>
<Imageview Android: layout_height = "wrap_content" Android: src = "@ drawable/img02"
Android: Id = "@ + ID/imageview2" Android: layout_width = "wrap_content"
Android: layout_x = "174dip" Android: layout_y = "38dip"> </imageview>
<Textview Android: layout_height = "wrap_content" Android: text = "textview"
Android: layout_x = "98dip" Android: Id = "@ + ID/textview1"
Android: layout_width = "wrap_content" Android: layout_y = "122dip"> </textview>
<Button Android: layout_height = "wrap_content" Android: Id = "@ + ID/button1"
Android: layout_x = "93dip" Android: text = "button" Android: layout_width = "wrap_content"
Android: layout_y = "173dip"> </button>
</Absolutelayout>

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.