I need to have a Edittext beside a Search button. The EditText should fill as much of the width as possible, the button should be to the right and be just big enough to have it’s text.
It looks like this now:
[EDIT TEXT][Search]
but should look like this:
[.......EDIT TEXT.......][Search]
Here is the XML:
<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content">
<EditText android:id="@+id/search_box"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="type to filter"
android:inputType="text"
android:maxLines="1" />
<Button android:id="@+id/search_text"
android:layout_toRightOf="@id/search_box"
android:text="Search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
Does it have to be Relative Layout?
I would suggest the following: set
EditTextlayout_widthtofill_parentand itslayout_weightto 1, something like this: