Jon Jon - 12 days ago 6
Android Question

Remove dark borders from autocompletetextview results

enter image description hereThis question is best explained with the above screenshot. As you can see, typing text into the autocompletetextview shows the results with a dark background behind them that has upper and lower padding. I haven't been able to find out where this dark background layout comes from and I would very much like to either get rid of it entirely, or else at least get rid of the upper and lower dark padding. For the autocompletetextview I have a custom adapter that makes use of a layout for each element in the list.. but as far as I know that's the only layout file I'm using for the view.

Here's the code for the autocompletetextview in the toolbar layout:

<AutoCompleteTextView
android:id="@+id/search_box"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/auto_complete_background"
android:layout_toLeftOf="@id/search_icon"
android:layout_toStartOf="@id/search_icon"
android:layout_toRightOf="@id/tvTitle"
android:layout_toEndOf="@id/tvTitle"
android:dropDownSelector="@color/cyan_light"
android:dropDownVerticalOffset="@dimen/abc_action_bar_default_height_material"
android:dropDownHorizontalOffset="-15dp"
android:dropDownWidth="match_parent"
android:dropDownHeight="wrap_content"
android:gravity="center_vertical"
android:hint="@string/search_hint"
android:textColorHint="@color/white_semi_transparent"
android:inputType="textAutoComplete"
android:popupBackground="@color/white"
/>


And here is the code for the layout for each element in the list:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|center_vertical"
>

<TextView
android:id="@+id/search_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="start|center_vertical"
android:maxLines="1"
android:paddingBottom="15dp"
android:paddingLeft="10dp"
android:paddingStart="10dp"
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:paddingTop="15dp"
android:scrollHorizontally="false"
android:text="@string/placeholder_name"
android:textColor="@color/black"
android:textSize="20sp" />

<TextView
android:id="@+id/search_item_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/search_item_name"
android:layout_alignBottom="@+id/search_item_name"
android:layout_toRightOf="@+id/search_item_name"
android:layout_toEndOf="@+id/search_item_name"
android:gravity="start|center_vertical"
android:maxLines="1"
android:ellipsize="end"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:scrollHorizontally="false"
android:text="@string/placeholder_address"
android:textColor="@color/cyan"
android:textSize="20sp" />

</RelativeLayout>


Where is the dark background layout coming from and how can I get rid of it?

UPDATE:

By removing the line of code:

android:popupBackground="@color/white"


I managed to make it look like in the second screenshot - no dark borders. On the other hand, now my results appear on a grey background and I'd like it to be white. Any way I can do this without using popupBackground?

enter image description here

Jon Jon
Answer

The solution turned out to be two things:

1) Removing the line:

android:popupBackground="@color/white"

from the autocompletetextview element

2) Adding the line:

android:background="@color/white"

to the relativelayout for the result rows

Comments