8

So my app theme extends from AppCompat's Material Light theme with Dark Action Bar.

I applied an accent color.

Now I am trying to use a Spinner on a dark backround and because of the theme, the spinner has a dark gray arrow which changes to accent color when pressed.

How can I make this spinner's arrow white so that it is prominent on a dark background?

Here's the image of the Spinner: enter image description here

  • Can you post a screenshot? If the dark area is created in Java you can look into `ContextThemeWrapper`. – Eugen Pechanec Jan 22 '15 at 03:16
  • @EugenPechanec I attached an image of the spinner. –  Jan 22 '15 at 15:52
  • I'd like the right arrow you see to be white in color while maintaining the accent color I applied. –  Jan 25 '15 at 22:19
  • The arrow is part of spinner's background so I'd go with a layer drawable with ripple on API 21+ and pre-colored chevron, because I can't tint in XML before Lollipop. – Eugen Pechanec Jan 26 '15 at 03:11

3 Answers3

4

If you want to apply same spinner style app wide, then in your values/styles.xml, override spinnerStyle with your custom style, which derives from an appcompat type and override android:background:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="android:spinnerStyle">@style/AppSpinner</item>
</style>

<style name="AppSpinner" parent="Widget.AppCompat.Spinner">
    <item name="android:background">@drawable/your_spinner_background</item>
</style>

If you need a quick way to generate a spinner background, try android-holo-colors, choose Colored Spinner and supply your accent color.

hidro
  • 12,333
  • 6
  • 53
  • 53
  • your answer helps if I am working with pre lollipop and I simply have to use a selector drawable and replace it in my theme as you explained, but with the new appcompat and lollipop widget accenting there should be a different way of doing it. –  Jan 25 '15 at 22:18
3

So the support library 22.1 enables use of android:theme attribute on views. That should help here.

0

with android:background you can specify your own background resource. I find the arrow rather useless (tapping the spinner brings dropdown menu even without arrow) so if you don't want to draw a custom arrow image, just leave the background black or transparent.

cyanide
  • 3,885
  • 3
  • 25
  • 33