For those who need an answer to this question and to solve this problem without giving an alternative, the answer is quite simple. You need to tell each control where to position each other and apply it to the control that should take the available android:layout_width = "match_parent" space android:layout_width = "match_parent" , although in LinearLayout this will cause all other controls to align out of the screen, in RelativeLayout it works great
<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:paddingTop="10dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="To: " android:textColor="#000000" android:paddingTop="10dp" android:layout_toLeftOf="@+id/editText_recipient" android:layout_alignParentLeft="true" android:layout_marginLeft="10dp"/> <EditText android:id="@+id/editText_recipient" android:layout_height="wrap_content" android:layout_width="MATCH_PARENT" android:hint="Enter number" android:inputType="number" android:textSize="12sp" android:layout_toLeftOf="@+id/button_recipient_picker" android:layout_marginLeft="5dp"/> <Button android:id="@+id/button_recipient_picker" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Browse .." android:layout_alignParentRight="true" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:onClick="doLaunchContactPicker"/> </RelativeLayout>
Br0thazs0ul
source share