我有这个' colors.xml'文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Absolute colors -->
<color name="red">#FF0000</color>
<!-- Application colors -->
<string name="error_message_color">@color/red</string>
</resources>
我使用Application Color以这种方式设置TextView文本颜色:
<TextView
android:id="@+id/error_message_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/error_message_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@string/error_message_color"
android:visibility="invisible"/>
但现在,使用Eclipse ADT 23.0.2.1259578部分
<string name="error_message_color">@color/red</string>
给出此错误:意外的资源引用类型; @string /
的预期值我无法编译。
为什么这样?有人知道我该如何解决?
PS:我知道如果我在textColor属性中使用@ color / red,问题就会解决,但我会保留&#34;应用程序颜色&#34;编码风格...由于
答案 0 :(得分:1)
如果您真的想要为颜色添加别名,请尝试引用颜色中的颜色并使用颜色。
<!-- Absolute colors -->
<color name="red">#FF0000</color>
<!-- Application colors -->
<color name="error_message_color">@color/red</color>
...
android:textColor="@color/error_message_color"