Search code examples
androidimagebuttonautocompletetextviewnine-patch

Implementing autocompletetextview next to ImageButton using 9patch in a RelativeLayout


I'm having trouble implementing a SearchBox with an ImageButton to the right using assets provided by a designer. I'm not sure if the problem is because of the assets or my implementation.

It should look like this, and it does in hdpi phones.

But look how it looks like in xhdpi emulated phone

It was tested on real devices too. Every devices without hdpi looks like the second example. This is my implementation:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#e9e9e9" >

<ImageButton 
    android:background="@drawable/home_btn_ubicacion"
    android:src="@drawable/home_icono_ubicacion"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:id="@+id/button"/>
<AutoCompleteTextView 
    android:layout_toLeftOf="@id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/home_input_buscar"
    android:hint="Ciudad o Barrio"
    android:layout_alignParentLeft="true"
    />

I'm not allowed to post images because of my reputation so I'm sharing the whole test project on github at: github.com/ejmedina/SearchBoxTestProject

Again, it doesn't look like a link because of low rep. Thank you all in advance as always.


Solution

  • The designer sent new assets which fixed the problem.

    It seems he made the first ones with Photoshop and the patch didn't worked as intended.

    I've pushed the new assets to my github repo and they will remain there for educational purpose.