0

Surfing the web I've found this site which generates Android custom themes. I've used it to create my personal theme: it inherits from Android:Widget.Holo (should be the dark one with white text) and some fancy widget witha a custom color. Because the theme inherits from Android:Widget.Holo, I have dark background and white text; but in some activity i need the opposite: white background with dark text.

When it comes to change the text color of most item i can do it easily using android:textColor="@android:color/black", but when i try to use it on spinner item it does nothing.

I've tried to create a new style only for spinner items, but i canno't apply it...

This is the first style generated (white text on black background):

<style name="SpinnerAppTheme" parent="android:Widget.Holo.Spinner">
        <item name="android:background">@drawable/apptheme_spinner_background_holo_dark</item>
        <item name="android:dropDownSelector">@drawable/apptheme_list_selector_holo_dark</item>
    </style>

And this is the second I've generated (the opposite, back text on white background):

    <style name="SpinnerDarkTextAppTheme" parent="android:Widget.Holo.Light.Spinner">
        <item name="android:background">@drawable/apptheme_spinner_background_holo_light</item>
        <item name="android:dropDownSelector">@drawable/apptheme_list_selector_holo_light</item>
        <item name="android:textColor">@android:color/black</item>
    </style>

But when I use style="@style/SpinnerDarkTextAppTheme nothing happens.

How can I do to have 2 different styles (obviously working at the same time) for my spinners?

SOLVED using this piece of code.

Community
  • 1
  • 1
Luca
  • 823
  • 4
  • 11
  • 31

1 Answers1

1

You can create two themes in the XML and switch between them before you set the content view:

Another approach:

Community
  • 1
  • 1
amalBit
  • 12,041
  • 6
  • 77
  • 94
  • I've tried both, but that's not what I need. I want to change color of **displayed text**. – Luca Sep 08 '14 at 10:45
  • I've tried your solution, but how can I use 2 different style for displayed text (one on dark background and one in white background) on spinner? Also the entries are loaded from a string-array – Luca Sep 08 '14 at 12:24