width - Android RelativeLayout and childs with layout_width="match_parent" -
how android calculates size of view when have 2 views @ same "row", 1 width="fill_parent"?
example:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <edittext android:id="@+id/edittext01" android:hint="enter text..." android:layout_alignparentleft="true" android:layout_width="match_parent" android:layout_toleftof="@+id/button01" android:layout_height="wrap_content"></edittext> <button android:id="@+id/button01" android:text="press here!" android:layout_width="wrap_content" android:layout_alignparentright="true" android:layout_height="wrap_content"></button> </relativelayout>
this code gives free space edittext , show button right. changes edittext fills width , button out of screen:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <edittext android:id="@+id/edittext01" android:hint="enter text..." android:layout_alignparentleft="true" android:layout_width="match_parent" android:layout_height="wrap_content"></edittext> <button android:id="@+id/button01" android:text="press here!" android:layout_width="wrap_content" android:layout_torightof="@+id/edittext01" android:layout_height="wrap_content"></button> </relativelayout
android:layout_toleftof="@+id/button01"
force right bound of edittext
align left side of button
, android ignores match_parent
width forcing width fill left parent side right side of button.
android:layout_torightof="@+id/edittext01"
force left bound of button
align right side of edittext
, since edittext
match_parent
width rights side aligned right side of parent view , android force button off screen.
Comments
Post a Comment