Breaking News
Home / Android / Android Snippets / How do you define colors to be used in layouts in an Android App?

How do you define colors to be used in layouts in an Android App?

Answer
In order to define a colors that can be used in your app, define it an a resource file.

e.g. the resource file can be named as color.xml in the res/values directory of your project as:

res/values/color.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <color name="White">#FFF</color>
  4.     <color name="Black">#000</color>
  5.     <color name="Grey">#7F7F7F</color>
  6. </resources>
[pb_builder]

Check Also

How to check if an Android device can connect to Internet?

The following code snippet shows how to check if an Android device can connect to …

Advertisment ad adsense adlogger