9

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>

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?

L84
  • 974
  • 2
  • 11
  • 21

1 Answers1

51

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:

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>

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>

Now you have a green divider on your Spinner :)

Community
  • 1
  • 1
jademcosta
  • 1,528
  • 15
  • 23