I. Relativelayout (relative layout) Focus:
In the absence of a pointing position, Relativelayout will default to the top left corner of the generated control
So you must add the property android:id= "@+id/name" to define the name of the control, and other controls can find it relative to the layout by @id/name
Two. Relativelayout (relative layout) related properties:
Three. Example
1. First create a relativelayout XML file
The code is as follows:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent" >5 6 <Button7 8 Android:id= "@+id/cbut"9 Android:layout_width= "Wrap_content"Ten Android:layout_height= "Wrap_content" One android:layout_centerinparent= "true" A Android:text= "Middle" - - /> the - <Button - - Android:id= "@+id/tbut" + Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" + android:layout_centerinparent= "true" A Android:layout_above= "@id/cbut" at Android:text= "Top" - - /> - - <Button - in Android:id= "@+id/tlbut" - Android:layout_width= "Wrap_content" to Android:layout_height= "Wrap_content" + android:layout_centerinparent= "true" - Android:layout_above= "@id/cbut" the Android:layout_toleftof= "@id/tbut" * Android:text= "upper left" $ Panax Notoginseng /> - the <Button + A Android:id= "@+id/trbut" the Android:layout_width= "Wrap_content" + Android:layout_height= "Wrap_content" - android:layout_centerinparent= "true" $ Android:layout_above= "@id/cbut" $ Android:layout_torightof= "@id/tbut" - Android:text= "Top Right" - the /> - Wuyi <Button the - Android:id= "@+id/bbut" Wu Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" About android:layout_centerinparent= "true" $ Android:layout_below= "@id/cbut" - Android:text= "Below" - - /> A + <Button the - Android:id= "@+id/lbut" $ Android:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" the android:layout_centerinparent= "true" the Android:layout_toleftof= "@id/cbut" the Android:text= "Left" - in /> the the <Button About the Android:id= "@+id/rbut" the Android:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" + android:layout_centerinparent= "true" - Android:layout_torightof= "@id/cbut" the Android:text= "Right"Bayi the /> the - <Button - Android:id= "@+id/blbut" the Android:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" the Android:layout_alignbottom= "@+id/bbut" the Android:layout_alignleft= "@+id/lbut" - Android:text= "bottom Left" /> the the <Button the Android:id= "@+id/brbut"94 Android:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" the Android:layout_alignbottom= "@+id/bbut" the Android:layout_alignleft= "@+id/rbut"98 Android:text= "bottom Right" /> About - </Relativelayout>
The results of the operation are as follows:
The above is my understanding of relativelayout (relative layout)
One of the five largest android layouts relative to layout (relativelayout)