+2  A: 

With the work that you've already done, I think the easiest answer would be to change your LinearLayout to a RelativeLayout, so that you can set alignParentRight on the ImageView and add paddingRight as needed.

Another option is to create a custom view component: http://developer.android.com/guide/topics/ui/custom-components.html

Ian G. Clifton
Changing LinearLayout to RelativeLayout didn't allow me to stretch the EditText to fill_parent. If I did fill_parent, the ImageButton just wasn't there (EditText spanned the whole thing). I tried rightOf and leftOf, still didn't work. Thanks for your Tip, I ended up adding another RelativeLayout under the LinearLayout so that thee ImageView is relative to the EditText, that allowed me to Linearly stretch that group to the ImageButton. Something like this worked: http://pastebin.com/9FRqJC7y thanks :)
Mohamed Mansour
+1  A: 

I'd probably use a FrameLayout and do something like this:

<FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Some text..."
        />
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center_vertical"
        android:src="@drawable/...."
        />
</FrameLayout>

Notice the "layout_gravity" on the ImageView...

Mads Kristiansen