1This code used to be in here as well:
@Nanne It would be nice if your answer also mentioned that R.color.XXX is a reference to the color. Meaning that it needs to be dereferenced (as it is in your example), for clarity.
And of course, if you want to define your color in an XML file, you can do this:
Check out the complete manual of course, public class Color extends Object.
For a sanity check, I just tried it, because I had a project open anyway, and yes, it's nice and red ;D
I'm not sure what you mean? As in, dereferenced and so will use more resources or do you mean something else?
In addition, if the text is a link you need to use text.setLinkTextColor(...); in code or android:textColorLink="..." in XML
Is there any way of telling if a particular color value is going to let a text disappear?
This method is now deprecated in Android M. You can however use it from the contextCompat in the support library, as the example now shows.
Where you have an alpha-channel first, then the color value.
You can also insert plain HEX, like so:
You can use various functions from the Color class to get the same effect of course.
You should use:
because the getColor() function is deprecated1, you need to use it like so: