Using Relativelayout, you can specify the location of the child view that it contains by setting the relative position (where each view is relative to another view). Look at the code in the main.xml below:
<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout xmlns:android= "http://schemas.android.com/apk/res/" Android "android:id=" @+id/rlayout "android:layout_width=" fill_parent "android:layout_height=" "Fill_parent" &
Gt <textview android:id= "@+id/lblcomments" android:layout_width= "Wrap_content" android:layou
t_height= "Wrap_content" android:layout_alignparentleft= "true" android:layout_alignparenttop= "true" android:text= "Comments"/> <edittext android:id= "@+id/txtcomments" Android:
Layout_width= "Fill_parent" android:layout_height= "170px" android:layout_alignleft= "@+id/lblcomments" android:layout_below= "@+id/lblcomments" android:layout_centerhorizontal= "true" android:textsize= "1
8sp "/> <button android:id=" @+id/btnsave "android:layout_width=" 125px " Android:layout_height= "Wrap_content" android:layout_alignright= "@+id/txtcomments" android:layout_below= "@+id"
/txtcomments "android:text=" Save "/> <button android:id=" @+id/btncancel " Android:layout_width= "124px" android:layout_height= "wrap_content" android:layout_alignleft= "@+id/txtC Omments "android:layout_below=" @+id/txtcomments "android:text=" Cancel "/> </relativela Yout>
As you can see, these views are embedded in the relativelayout, and each view has some unique properties to align with the other view. These properties are:
Layout_alignparenttop
Layout_alignparentleft
Layout_alignright
Layout_below
Layout_centerhorizontal
The values of these properties are the IDs of each referenced view.
Effect Chart:
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/