<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal" >
<EditText
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="40dp"
android:text="EditText"
android:textSize="18sp" />
<ImageButton
android:layout_gravity="center_vertical"
android:layout_width="40dp"
android:layout_height="40dp" />
</LinearLayout>
Just i change layout_width of EditText fill_parent to 0dp and set layout_weight="1", so it will stretched and take remaining space.
Check this for LinearLayout weight concept.