Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android changing colors with themes

Tags:

android

themes

I am trying to provide user settable colors in my app. White text on black background and black text on white background. I have multiple layouts with many listviews, both standard and custom adapters. People have suggested using Themes, but I have had no luck changing the text colors across all layouts. Can anyone show me an actual Theme layout that can accomplish this? I can easily change the background colors using myscreen.setBackGroundColor(xx), but when I try to change the text with a theme, it also changes spinner text as well.

like image 348
miannelle Avatar asked Dec 12 '22 21:12

miannelle


1 Answers

Use

    <item name="android:spinnerStyle">@style/StandardSpinner</item>
    <item name="android:spinnerItemStyle">@style/StandardSpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/StandardSpinnerDropDownItem</item>

in your theme, this will override the Text style.

Your style will look something like this:

<style name="StandardSpinner" parent="@android:style/Widget.Spinner">
    <item name="android:background">@drawable/spinner</item>
</style>

<style name="StandardSpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:textAppearance">@style/GameDisplayText</item>
    <item name="android:gravity">center_vertical|center_horizontal</item>
</style>

<style name="StandardSpinnerDropDownItem" parent="@android:style/Widget.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/GameDisplayText</item>
</style>
like image 121
jax Avatar answered Jan 05 '23 13:01

jax