Search code examples
androidautocompletetextview

Style on AutoCompleteTextView dropdown


I've been trying to set the style of my dropdown for the autocomplete for some time now. At the moment it looks like this:

enter image description here

The green area is the dropdown with alternatives. I would like to make that box smaller, since it does'nt look very good at the moment with my rounded rectangle.

How do i achieve this? So far I have only been able to adjust each line in it..


Solution

  • Found out myself 5 minutes after putting the question here. I'll keep the question up for someone who might come across this.

    You can simply put dropdown attributes when you create the autocompletetextview.

    android:dropDownWidth="yourWidth"
    

    Coudln't find any xml attribute for setting dropdown backgroundresource but the programmatical way works fine:

    autoTextView.setDropDownBackgroundDrawable(this.getResources().getDrawable(R.drawable.rounded_rectangle));
    

    This way you can define how the dropdown should look with your own drawable. If you would want to change it with xml from resource, this is an approach:

    android:completionHintView="@layout/your_layout"