Книга: Beginning Android
Colors
Colors
Colors in Android are hexadecimal RGB values, also optionally specifying an alpha channel.
You have your choice of single-character hex values or double-character hex values, leaving you with four styles:
• #RGB
• #ARGB
• #RRGGBB
• #AARRGGBB
These work similarly to their counterparts in Cascading Style Sheets (CSS).
You can, of course, put these RGB values as string literals in Java source or layout resources. If you wish to turn them into resources, though, all you need to do is add color elements to the resources file, with a name attribute for your unique name for this color, and a single text element containing the RGB value itself:
<resources>
<color name="yellow_orange">#FFD555</color>
<color name="forest_green">#005500</color>
<color name="burnt_umber">#8A3324</color>
</resources>
In a layout, you can reference colors as @color/...
, replacing the ellipsis with your unique name for the color (e.g., burnt_umber
). In Java, you reference color resources by the unique name prefixed with R.color.
(e.g., Resources.getColor(R.color.forest_green)
).
- 10.3.4 Changing Colors
- Fields of Green. Or Other Colors.
- 10.3 Modifying Fonts and Colors
- Шаблон: значение по умолчанию
- Elements of the xorg.conf File
- The GNU Image Manipulation Program
- Class Inheritance
- 3.1.8 Constants
- 3.1.13 Enumerated Variables
- 10.3.3 Customizing Fonts Through Custom
- Поддержание состояния в специальном элементе управления
- Miscellaneous Values