So i have this textview "To", an edittext to input the contact and a search button to search for contacts all in one line. The textview and button are all in good place but the problem is the edittext is small, i want it occupy all the remaining spaces. Here's the code:
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_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="wrap_content"
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>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_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_marginLeft="10dp"/>
<EditText
android:id="@+id/editText_recipient"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Enter Number"
android:inputType="number"
android:textSize="12sp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
/>
<Button
android:id="@+id/button_recipient_picker"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Browse .."
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:onClick="doLaunchContactPicker"/>
</LinearLayout>
use this layout, i converted your layout to linear (horizontal default). and added a layout_weight to editText, it will occupy the remaining space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With