当禁用依赖于preferences显示错误的颜色字体 [英] Dependent preferences display wrong color font when disabled

查看:246
本文介绍了当禁用依赖于preferences显示错误的颜色字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我用几个preferences,包括其中的一些使用以下属性依赖关系:的android:依赖=preF_KEY

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

基本上,当未选中该复选框,其他所有的preferences下面被禁用:

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

发生的问题,当我回来设置以下3条线路在我的自定义主题:

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>
(...)

这3个属性定义的颜色也改写禁用preferences的默认字体颜色:

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

在preferences仍远禁用,但显示使字体认为恰恰相反...

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

我搜索默认的Holo风格的轻和主题,但我不知道在哪里这个定义,为什么上面的风格覆盖这些的。

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?

感谢您的帮助。

推荐答案

您应该定义颜色状态列表,并把它放在/ RES /彩色文件夹内。

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>

这篇关于当禁用依赖于preferences显示错误的颜色字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆