Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependent preferences display wrong color font when disabled

In my app I am using several preferences, including some of them related with dependencies using the following attribute: android:dependency="pref_key".

Basically, when the checkbox is not selected, all the other preferences below are disabled:

Preferences without style definition

The problem happens when I setup back the following 3 lines in my custom theme:

<style name="AppThemeOrange" parent="@style/AppTheme">
        <item name="android:textColorPrimary">@color/OrangeMain</item>
        <item name="android:textColorSecondary">@color/OrangeDark</item>
        <item name="android:textColorTertiary">@color/OrangeLight</item>
(...)

The colors defined on these 3 attributes also override the default font color of the disabled preferences:

Preferences with style definition

The preferences are still well disabled, but the fonts displayed make believe the contrary...

I searched in the default Holo Light styles and theme, but I have no idea where this is defined and why the styles above override these ones.

Did anyone already meet the problem?

like image 520
Yoann Hercouet Avatar asked Jun 15 '13 11:06

Yoann Hercouet


1 Answers

you should define a color state list and put it inside the /res/color folder

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_enabled="false" android:color="#FF00ff00"/>
    <item android:color="#FFff0000"/>
</selector>
like image 68
Blackbelt Avatar answered Nov 19 '22 02:11

Blackbelt