android:textColor在棉花糖中不再有效

android:textColor在棉花糖中不再有效,android,android-styles,android-6.0-marshmallow,cyanogenmod,Android,Android Styles,Android 6.0 Marshmallow,Cyanogenmod,我已经编写了一个应用程序,它依赖于参考资料中定义的颜色。有些是直接在布局XML文件中设置的,另一些是在代码中设置的。示例: res/values/styles.xml中的颜色定义: <color name="orvGyro">#33B5E5</color> 该应用程序以API 17为目标。直到棒棒糖,这已经完美地工作,显示正确的颜色。在迁移到棉花糖(Cyanogenmod 13)后,所有这些颜色都显示为橙色。其他颜色(在Java代码中定义,而不是在参考资料中定义)似乎显

我已经编写了一个应用程序,它依赖于参考资料中定义的颜色。有些是直接在布局XML文件中设置的,另一些是在代码中设置的。示例:

res/values/styles.xml
中的颜色定义:

<color name="orvGyro">#33B5E5</color>
该应用程序以API 17为目标。直到棒棒糖,这已经完美地工作,显示正确的颜色。在迁移到棉花糖(Cyanogenmod 13)后,所有这些颜色都显示为橙色。其他颜色(在Java代码中定义,而不是在参考资料中定义)似乎显示正确

我尝试将目标API更改为23,并为API21+添加样式,但没有效果

这里怎么了?这是氰化物13中的一个错误,还是我做错了什么

编辑:似乎不是从资源中获取颜色。对如下所示的颜色进行硬编码也会使我看到橙色文本:

<TextView
    android:id="@+id/textView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/dotSpace"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#669900" />
使用类,它是一个帮助类,用于以向后兼容的方式访问API级别4之后引入的上下文中的功能

accStatus.setTextColor(ContextCompat.getColor(context, R.color.somecolor));


返回与特定资源ID关联的颜色

明白了

无论我在哪里遇到这个问题,控件中显示的文本都是一个正方形(U+2b1b)。当我更改此文本时(例如,通过附加X),只有正方形将显示为橙色,字符串的其余部分具有所需的颜色


把它改成一个小正方形(U+25fc)固定的东西。其他一些特殊字符会给我其他颜色——显然,棉花糖上的某些字符固定为某些颜色,而在早期版本中,它们可以像其他任何文本一样设置样式。

在我的Sony Xperia(Android 6.0棉花糖)上也遇到了同样的问题。原因是启用了设置/辅助功能/高对比度文本(实验)


当我禁用它时,它再次正常工作。

对于直接在版面中设置的颜色,我该怎么办?它将从您的颜色资源中获取适当的颜色。这正是不起作用的。即使在布局中指定颜色资源,它也将显示为橙色。
<TextView
    android:id="@+id/textView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/dotSpace"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#669900" />
    TextView newType = new TextView(rilLteCells.getContext());
    newType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newType.setTextAppearance(rilLteCells.getContext(), android.R.style.TextAppearance_Medium);
    newType.setTextColor(rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cell.getGeneration())));
    newType.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));
    row.addView(newType);
accStatus.setTextColor(ContextCompat.getColor(context, R.color.somecolor));