I am trying to set the text colour programatically from a colour resource during onCreate and am getting some wierd results.
I have a colour resource defined in res\colors.xml:
my activity then uses the following code to retrieve the colour:
int WheelColour = getResources().getColor(R.color.wheelFill);
Finally I assign it to a Paint:
When I run my application the colour does not get set an I get a log message from the getColor line claiming that "Color value 'List' must start with #". 'List' is the value of one of my string resources so clearly something is getting messed up there.
If I bypass the resource and use:
int WheelColour = Color.argb(0xC0, 0xFF, 0xFF, 0xFF);
Everything works correctly so it has to be the getColor call but I can't see what's wrong with it. (I have tried explicitly using a context which made no difference).
Has anybody else come across this or sucessfully managed to set paint colours from colour resources? maybe your R.java got messed up and isn't linking to the correct resource. clean the project and refresh
以上就是Colour resource ID returning wrong value的详细内容，更多请关注web前端其它相关文章！