Relativelayout, also known as relative layout, is a very common layout.
Unlike the linearlayout arrangement rules, it is more casual, and it can be used in a relatively positioned way to make the control appear anywhere in the layout.
By relative layout we can implement something like this:
android:layout_centerhorizontal="True" allows the control to be centered horizontally by this property
Android:layout_alignparentbottom="true" this property allows the control to be at the bottom
android:layout_centervertical="true" this property causes the control to be centered vertically
android:layout_alignparentright="true" this property causes the control to be on the right side of the parent layout
android:layout_centerinparent="true" this property causes the control to be in the center of the parent layout
android:layout_toleftof="@id/button" This property causes the control to be located to the left of the control with the ID button
android:layout_torightof="@id/button" the same, the control is on the right side of the button
android:layout_above="@id/button" is above the button
Android:layout_below="@id/button" is located below the button
The following code allows you to implement this interface using the above method.
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" Match_parent "> <button android: Layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_centerhorizontal= "true" android:text= "Attack"/> <button android:layout_width= "wrap_content" android:layout_height= "Wrap_con" Tent "android:layout_alignparentbottom=" true "android:layout_centerhorizontal=" true "android:text=" escape "/> <button android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Androi D:layout_centervertical= "true" android:text= "left hook fist"/> <button android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentright= "true" android:layout_centervertic Al= "true" android:text= "right hook"Fist "/> <button android:id=" @+id/button "android:layout_width=" Wrap_content "android:layout_he ight= "Wrap_content" android:layout_centerinparent= "true" android:text= "must Kill"/> <button Androi D:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_centervertical= "true" android:layout_toleftof= "@id/button" android:text= "left"/> <button android:layout_width= "Wrap_cont Ent "android:layout_height=" Wrap_content "android:layout_centervertical=" true "android:layout_toright of= "@id/button" android:text= "right"/> <button android:layout_width= "Wrap_content" Android:layo ut_height= "Wrap_content" android:layout_above= "@id/button" android:layout_centerhorizontal= "true" and roid:text= "on"/> <button android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_below= "@id/button" android:layout_centerhorizontal= "true" android:text= "under"/></relativelayout>
Android---4---layout of relativelayout