5.4.4. colors.xml

This app displays correct answers in green and incorrect answers in red. As with any other resource, color resources should be defined in XML so that you can easily change colors without modifying your app’s Java source code. Typically, colors are defined in a file name colors.xml, which you must create. As you learned in Section 3.4.5, colors are defined using the RGB or ARGB color schemes.

To create the file and configure the two color resources, perform the following steps:

1. In the project’s res folder, right click the values folder, then select New > Android XML File to display the New Android XML File dialog.

2. Specify colors.xml in the File field and click Finish to create the file.

3. If the IDE opens the new file ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.