I'm using MultiAutoCompleteTextView
in my Android app. I need to customize the suggestion list of this control. I've tried this to customize the list separator color but this didn't worked for me. How can I update the default list divider color of MultiAutoCompleteTextView
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In addition to setting the divider
color, you need to also set the dividerHeight
property or it won't work. And the Popup
used by the MultiAutoCompleteTextView
is actually a ListView
, so setting that is correct here.
Add this to your styles.xml file:
<style name="myStyle" parent="@android:style/THeme.Holo.Light"> <!-- or whatever style you inherit -->
<item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
</style>
<style name="DropDownListViewStyle" parent="android:style/Widget.ListView.DropDown">
<item name="android:divider">@android:color/holo_orange_dark</item>
<item name="android:dividerHeight">2px</item>
</style>
This will set the dividers in the MultiAutoCompleteTextView
's Popup
to orange.
回答2:
You can set the divider color of the ListView showing your results. This is set with the divider
attribute.
Like this: android:divider="@color/mycolor
As an alternative, you could also create a custom drawable using a ShapeDrawable, that contains it's own custom divider color, then you apply that drawable as the background to your list element.