tags:

views:

504

answers:

2

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.

+1  A: 

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>
jax
A: 

Just some extra information, in order to point you theme to your application you need to define it at the AndroidManifest.xml

ex.

<application android:icon="@drawable/icon" android:label="@string/app_name"    android:theme="@style/Theme">

you should reuse some of the defaults styles properties, so declare the android default theme as parent theme of yours

at values/styles.xml or wherever is your theme file

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme" parent="@android:style/Theme">
         <!-- Widget styles -->
         <item name="android:spinnerStyle">@android:style/Widget.Spinner</item>
         <item name="android:spinnerDropDownItemStyle">@style/Widget.DropDownItem.Spinner</item>
         <item name="android:spinnerItemStyle">@android:style/Widget.TextView.SpinnerItem</item>
    </style>
Andres Yajamin