BoD/android-switch-backport

Text color of switch not set correctly

Closed this issue · 2 comments

I am a first time user of the switch backport. Thnx for making this code available.

I have trouble getting the text to appear correctly. In my sample project the text has not color (is just grey). This means that the "OFF" state text is not readable since the text is the same color as as the grey background. This is different from the sample app that comes with the switch backport where text is displayed in a light grey.

I am unable to set the text color myself with xml attributes.

When I comment out lines 178-184 from Switch.java, text is displayed correctly:

        colors = appearance.getColorStateList(R.styleable.Android_android_textColor);
        if (colors != null) {
            mTextColors = colors;
        } else {
            // If no color set in TextAppearance, default to the view's textColor
            mTextColors = getTextColors();
        }

into

        //colors = appearance.getColorStateList(R.styleable.Android_android_textColor);
       // if (colors != null) {
       //     mTextColors = colors;
       // } else {
            // If no color set in TextAppearance, default to the view's textColor
            mTextColors = getTextColors();
        //}

Is there an obvious thing that I am doing wrong here?

BoD commented

Hi!
Well, I don't see anything obvious that could cause this problem.
It looks like a theme problem (like dark vs light theme), but it's hard
to tell.
The only thing I can suggest is to compare the sources of your project
with the sources of the sample and try to spot any differences... Not
much of a "solution", I know :)
Hope you'll find the problem!

BoD
Sent from my TV.

On 24/01/2014 06:09, Pimmelorus wrote:

I am a first time user of the switch backport. Thnx for making this
code available.

I have trouble getting the text to appear correctly. In my sample
project the text has not color (is just grey). This means that the
"OFF" state text is not readable since the text is the same color as
as the grey background. This is different from the sample app that
comes with the switch backport where text is displayed in a light grey.

I am unable to set the text color myself with xml attributes.

When I comment out lines 178-184 from Switch.java, text is displayed
correctly:

     colors  =  appearance.getColorStateList(R.styleable.Android_android_textColor);
     if  (colors  !=  null)  {
         mTextColors  =  colors;
     }  else  {
         // If no color set in TextAppearance, default to the view's textColor
         mTextColors  =  getTextColors();
     }

into

     //colors = appearance.getColorStateList(R.styleable.Android_android_textColor);
    // if (colors != null) {
    //     mTextColors = colors;
    // } else {
         // If no color set in TextAppearance, default to the view's textColor
         mTextColors  =  getTextColors();
     //}

Is there an obvious thing that I am doing wrong here?


Reply to this email directly or view it on GitHub
#38.

BoD commented

The light theme was actually incorrect, which was probably the source of this problem. It has been fixed now, closing this issue.