Android微调器分隔线颜色 [英] Android spinner divider color
问题描述
我有一个像这样的微调框
I have a spinner styled like this
<style name="OptionsSpinner" parent="android:Widget.Spinner">
<item name="android:background">@drawable/spinner_background</item>
<item name="android:spinnerMode">dropdown</item>
<item name="android:dropDownListViewStyle">@style/SpinnerDropdown</item>
</style>
<style name="SpinnerDropdown">
<item name="android:divider">#ff0000</item>
</style>
,但是SpinnerDropDown样式没有任何效果,分隔线为灰色或任何默认值.如何在微调器中设置分隔线的样式?
but the style SpinnerDropDown doesn't have any effect, the divider is grey or whatever the default is. How do I style the dividers in a spinner?
推荐答案
您是直接在 Spinner
小部件的 style
属性中使用此样式吗?如果是这样,那就是为什么它不起作用的原因.您应该使用应用程序的 theme
设置分隔符的样式.
You are using this style directly in the style
property of your Spinner
widget?
If so, that's why it's not working. You should style the divider using the theme
of your application.
要设置分隔线的样式,请执行以下操作:
To style the divider, do the following:
在您的应用程序主题中,您应该具有 item
android:dropDownListViewStyle
:
In your application theme you should have the item
android:dropDownListViewStyle
:
<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:dropDownListViewStyle">@style/mySpinnerStyle</item>
</style>
而且,分隔符的样式(mySpinnerStyle)在以下位置定义:
And, the style of the divider (mySpinnerStyle) is defined in:
<style name="mySpinnerStyle" parent="android:Widget.ListView.DropDown">
<item name="android:divider">#00ff00</item>
<item name="android:dividerHeight">1dp</item>
</style>
现在,您的 Spinner
上有一个绿色分隔线:)
Now you have a green divider on your Spinner
:)
这篇关于Android微调器分隔线颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!