the relative layout manager refers to the placement of a reference to a different control, which can be controlled to place the component on the top, bottom, left, and right of a specified reference component, which can be done directly through the properties provided by each component. the basic use of each method is described below
No. |
Property name |
The corresponding rule constants |
Describe |
1 |
Android:layout_below |
Relativelayout.below |
Placed below the specified component |
2 |
Android:layout_toleftof |
Relativelayout.left_of |
Placed on the left side of the specified component |
3 |
Android:layout_torightof |
Relativelayout.right_of |
Placed on the right side of the specified component |
4 |
Android:layout_aligntop |
Relativelayout.align_top |
Align to the specified component as a reference |
5 |
Android:layout_alignbottom |
Relativelayout.align_bottom |
Align with the specified component for reference |
6 |
Android:layout_alignleft |
Relativelayout.align_left |
Left-justified as a reference for the specified component |
7 |
Android:layout_alignright |
Relativelayout.align_right |
Right-justified with reference to the specified component |
<span style= "FONT-SIZE:18PX;" ><relativelayout xmlns: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 "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" Android: Textalignment= "center" tools:context= ". Mainactivity "> <edittext android:id=" @+id/edittext1 "android:layout_width=" Wrap_content "an droid:layout_height= "Wrap_content" android:layout_alignparentright= "true" android:layout_alignparenttop= "Tru E "android:ems=" "/> <edittext android:id=" @+id/edittext2 "android:layout_width=" Wrap_cont Ent "android:layout_height=" wrap_content "android:layout_alignright=" @+id/edittext1 " android:layout_below= "@+id/edittext1" android:ems= "ten" android:inputtype= "Textpassword" > <re Questfocus/> </EditText> <textview android:id= "@+id/textview1" android:layout_width= "wrap _content "android:layout_height=" wrap_content "android:layout_alignbottom=" @+id/edittext1 "Android:la Yout_alignparentleft= "true" android:text= "account"/> <textview android:id= "@+id/textview2" Andro Id:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_alignbottom= "@+id/editTex T2 "android:layout_alignparentleft=" true "android:text=" password "android:textalignment=" center "/> & Lt Button android:id= "@+id/button1" android:layout_width= "wrap_content" android:layout_height= "Wrap_cont Ent "android:layout_below=" @+id/edittext2 "android:layout_marginleft=" 23DP "android:layout_margintop= "36DP" Android: layout_torightof= "@+id/textview2" android:text= "login"/> <textview android:id= "@+id/textview3" Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_alignbottom= "@ +id/button1 "android:layout_marginleft=" 14DP "android:layout_torightof=" @+id/button1 "Android:autolin k= "web" android:linksclickable= "true" android:text= "Forgot password" android:textappearance= "? Android:attr/texta Ppearancesmall "android:textsize=" 10DP "/></relativelayout></span>
The use of relative layout is the main layout, it is more convenient than other methods, can be visualized directly drag-and-drop interface.
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ... .. ....... There is no beauty in the dividing line ... ..... ..... ..... ..... ..... .......-.....-......................
using the dynamic table layout implementation is the same as before, not often used here no longer repeat, interested readers can try for themselves. There are several ways to use this.
1 |
Public Relativelayout.layoutparams (int w, int h) |
Structure |
Specify the width and height of the relativelayout layout |
2 |
public void addRule (int verb, int anchor) |
Ordinary |
Add a specified parameter rule |
3 |
Public int[] GetRules () |
Ordinary |
Get all parameter rules for a component |
Next forecast: Using nested layouts to implement the calculator interface