You can apply color resources to screen controls. You tag color resources with the
<color> tag and store them in the file /res/values/colors.xml. This XML
resource file is not created by default and must be created manually.
Here is an example of a color resource file:
<?xml version=”1.0” encoding=”utf-8”?>
<resources>
<color name=”background_color”>#006400</color>
<color name=”app_text_color”>#FFE4C4</color>
</resources>
The Android system supports 12-bit and 24-bit colors in RGB format. Given below is the list that how many color formats that the Android platform supports.
Color Formats Supported in Android
Format Description Example
#RGB 12-bit color #00F (blue)
#ARGB 12-bit color with alpha #800F (blue, alpha 50%)
#RRGGBB 24-bit color #FF00FF (magenta)
#AARRGGBB 24-bit color with alpha # 80FF00FF (magenta, alpha 50%)
The following code retrieves a color resource named app_text_color using the
getColor() method:
int textColor = getResources().getColor(R.color.app_text_color);
<color> tag and store them in the file /res/values/colors.xml. This XML
resource file is not created by default and must be created manually.
Here is an example of a color resource file:
<?xml version=”1.0” encoding=”utf-8”?>
<resources>
<color name=”background_color”>#006400</color>
<color name=”app_text_color”>#FFE4C4</color>
</resources>
The Android system supports 12-bit and 24-bit colors in RGB format. Given below is the list that how many color formats that the Android platform supports.
Color Formats Supported in Android
Format Description Example
#RGB 12-bit color #00F (blue)
#ARGB 12-bit color with alpha #800F (blue, alpha 50%)
#RRGGBB 24-bit color #FF00FF (magenta)
#AARRGGBB 24-bit color with alpha # 80FF00FF (magenta, alpha 50%)
The following code retrieves a color resource named app_text_color using the
getColor() method:
int textColor = getResources().getColor(R.color.app_text_color);
0 comments:
Post a Comment