MultiAutoCompleteTextView suggestion separator color

柔情痞子 提交于 2019-12-25 04:46:13

问题


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.



来源:https://stackoverflow.com/questions/27801498/multiautocompletetextview-suggestion-separator-color

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