How does Android calculate the size of a view when I have two views in the same "row", one with a 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 some 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 all the EditText free space and shows the button to the right of it. But with these changes, the EditText fills the entire width, and the button does not appear on the 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 some 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
juan source share