What you learn: You will learn how to specify Colors in an XML-Resource and how to use them in other xml-files and how to read them out to your code.
Difficulty: 1 of 5
Questions/Problems: Simply post below...
Defining colors in Javacode is not nice and not really flexible
Colors should be defined in a file called (i.e.) colors.xml in your project folder: /res/values/".
There are various possibilities of describing a color. All at least contain a HexChar for R(ed), G(reen) and B(lue). Before those values there can be an A(lpha), what is the Transparency of the Color.
So all possibilities are:
So a bright strong red would be #F00 or #FF00 or #FF0000 or #FFFF0000[/list].
Note: F is the highest of the Hex-Chars and 0 the lowest.
Example-File from the Christmas-Calendar-Tutorial:
Use them in other xml-Files (like style.xml or layout.xml) like the following:
To read out the Color to your Java-Code do the following: