Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show divider between spinner items?

I using listviews and expandedviews that has dividers and I can set them but on spinner its looks like it is no divider between items.

Someone that has a idea of how to fix this?

like image 951
RickardP Avatar asked Dec 31 '10 11:12

RickardP


2 Answers

This worked for me:

<style name="SpinnerStyle" parent="Widget.AppCompat.ListView.DropDown">         <item name="android:divider">#d1d1d1</item>         <item name="android:dividerHeight">0.5dp</item>     </style>  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">         <!-- Customize your theme here. -->         <item name="android:dropDownListViewStyle">@style/SpinnerStyle</item> 

The advantage of using this is that it doesn't remove the ripple effect on hover.

like image 109
X09 Avatar answered Oct 04 '22 13:10

X09


I managed to find a more proper solution for this issue (without including the divider in the single item layout).

What you have to do is define in your activity's theme

        <item name="android:dropDownListViewStyle">@style/App.Style.Spinner</item> 

and then create the proper style with

   <style name="App.Style.Spinner" parent="@style/Widget.Sherlock.Light.ListView.DropDown">            <item name="android:dividerHeight">10dip</item>            <item name="android:divider">@drawable/mydivider</item>    </style> 
like image 25
Talihawk Avatar answered Oct 04 '22 12:10

Talihawk