Can't use color value resource in style value res
I'm a newcomer in android development. Have no idea what's wrong with this. The color that I have been declared in colors.xml value res can't not be used in my styles.xml...
here is how I declared the color in colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="my_green">#59ab1b</color>
<color name="app_bgcolor">#ededed</color>
<color name="txt_grey">#707070</color>
</resources>
then when i try to put use it in my style xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="lbl_welcome">
<item name="android:textSize">17sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/my_green"</item>
</style>
</resources>
it's said like this:
开发者_运维知识库error: Error: No resource found that matches the given name (at 'android:textColor' with value '@color/ my_green"').
any idea?
thanks before!
Hey I just noticed your item tag has a quote mark in the end, like this:
<item name="android:textColor">@color/my_green"</item>
and it should read like this:
<item name="android:textColor">@color/my_green</item>
without the " after my_green.
At least this way it works for me. Hope it helps!
can you try this and tell me if it works
<resources>
<color name="my_green">#ff59ab1b</color>
<color name="app_bgcolor">#ffededed</color>
<color name="txt_grey">#ff707070</color>
</resources>
Make sure both file are in the 'values' folder within 'res'
use @android:color/your_color
eg. <item name="android:textColor">@android:color/my_green</item>
精彩评论