问题描述
我在Android应用中使用MultiAutoCompleteTextView
.我需要自定义此控件的建议列表.我已尝试此来自定义列表分隔符颜色,但这对我不起作用.如何更新MultiAutoCompleteTextView
的默认列表分隔符颜色?
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
?
推荐答案
除了设置divider
颜色,还需要设置dividerHeight
属性,否则该属性将不起作用.而且MultiAutoCompleteTextView
使用的Popup
实际上是ListView
,因此此处的设置正确.
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.
将此添加到您的styles.xml文件中:
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>
这会将MultiAutoCompleteTextView
的Popup
中的分隔线设置为橙色.
This will set the dividers in the MultiAutoCompleteTextView
's Popup
to orange.
这篇关于MultiAutoCompleteTextView建议分隔符颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!