11

I am trying to create a full width auto complete text field.

So far, I think I have the text field itself looking right. The problem is with the auto complete popup. It has this very bold shadow all around it and I just can't get rid of it.
Don't get me wrong, I still want the shadow, but a subtle shadow, only on the bottom of the popup, not all around it (especially not at the top, that's really weird).

Something like this: This is what I want.

Here's what mine looks like (sorry for giant image): What I have so far


The Code

activity_main.xml:

<AutoCompleteTextView
    android:id="@+id/actvSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="8dp"
    android:background="@drawable/full_width_input"
    android:completionThreshold="1"
    android:hint="Search a movie..."
    android:textColorHint="#BDBDBD"
    android:elevation="0dp"
    android:popupBackground="@android:color/white" />

full_width_input.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="-1dp" android:right="-1dp" android:left="-1dp">
        <shape android:shape="rectangle">
            <padding android:bottom="20dp" android:top="20dp" android:left="16dp" android:right="16dp" />
            <solid android:color="@android:color/white" />
            <stroke android:width="1dp" android:color="#E0E0E0" />
        </shape>
    </item>
</selector>
Gofilord
  • 6,239
  • 4
  • 27
  • 43

4 Answers4

11

use android:popupElevation="0"

<AutoCompleteTextView
    android:id="@+id/actvSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="8dp"
    android:background="@drawable/full_width_input"
    android:completionThreshold="1"
    android:hint="Search a movie..."
    android:textColorHint="#BDBDBD"
    android:popupElevation="0dp"
    android:popupBackground="@android:color/white" />
Abbath
  • 1,002
  • 13
  • 30
6

This question is a bit old already, but anyways. I just crossed through this problem. I was using android:popupBackground="@null" for my autocomplete, but it DOES NOT WORK PROPERLY ON ANDROID 6 (I just tested it).

Instead of using android:popupBackground="@null", use android:popupBackground="@android:color/transparent" (it will also work for the Android 4.4 and 5.0).

Rick
  • 521
  • 5
  • 18
5

If we set android:popupBackground="@null" in AutoCompleteTextView and set background for the adapter row as white, we can achieve this. Hope it will help you.

Vignesh
  • 51
  • 2
  • Thanks for the answer! I tried your solution and it's almost there. There is no shadow, but it seems like the white background for each row doesn't affect the actual background of items. Right now, it's like the list has a transparent background. – Gofilord Jul 03 '15 at 11:49
-5

What I ended up doing is manually creating the auto complete using a ListView.

It took a bit of hacking around but now I have the exact design I had in mind.

Gofilord
  • 6,239
  • 4
  • 27
  • 43