Style on AutoCompleteTextView dropdown

拜拜、爱过 提交于 2019-12-05 06:16:43

问题


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:

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..


回答1:


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"


来源:https://stackoverflow.com/questions/11497295/style-on-autocompletetextview-dropdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!