Search code examples
androidandroid-widgetspinnerandroid-3.0-honeycombandroid-4.0-ice-cream-sandwich

Android Change spinner pressed colour Light Holo theme


I am working on an Android Tablet app. I have created a custom action bar, and managed to style it the way I want, except for the spinners.

My main theme extends Holo Light meaning that when I press a spinner it goes blue. How do I change this?


Solution

  • Specify a custom style for android:actionDropDownStyle in your theme which itself has an android:background for your custom state-list drawable.

    Here's the one that's specified by default:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_enabled="false"
              android:drawable="@drawable/spinner_ab_disabled_holo_dark" />
        <item android:state_pressed="true"
              android:drawable="@drawable/spinner_ab_pressed_holo_dark" />
        <item android:state_pressed="false" android:state_focused="true"
              android:drawable="@drawable/spinner_ab_focused_holo_dark" />
        <item android:drawable="@drawable/spinner_ab_default_holo_dark" />
    </selector>
    

    You'll need to provide your own images for each one of these states (and for mdpi, hdpi, and xhdpi).

    You can modify the ones that come with the platform to make your life easier. Look in SDK/platforms/platform-14/data/res/ in the drawable-mdpi, drawable-hdpi, and drawable-xhdpi folders.