In Android with a color to represent the 32-bit integer, 32-bit integer contains 4 bytes, of which the first byte represents the color of the transparency (Alpha), 0 represents a completely transparent, 0xFF is completely opaque. 2,3,4 byte representing the color red in the RGB color space (R), green (G) and blue (B) values of three color components, the color component representing no 0, representing the color 0xFF component is maximized. For example 0xCCFF0000 red represents 80% transparency.
#RGB
#ARGB
#RRGGBB
#AARRGGBB
file path
res/values/colors.xml
Reference
java中:R.color.color_name
xml中:@Color/color_name
Within an XML # adding a color to represent the color value, e.g. # FFA1A100. If transparency to 0xFF, and that is completely opaque, the transparency may be omitted, for example, can be written as # FFA1A100 # A1A100.
XML tags can be acquired in good color configuration, the integer value can be directly used to represent a color by the color getColor ().
Note that, when the direct use of an integer value of a color to represent the color, transparency can not be omitted when 0xFF, otherwise they will think that transparency is 0, that is completely transparent, which cause the color can not be displayed.
Such as XML in color # A1A100, the code should be written 0xFFA1A100, but can not be written 0xA1A100.
listView.setDivider(new ColorDrawable(0xFFFF0000));
listView.setDividerHeight(1);
Custom Color Syntax
The following is a comparison table of transparency, transparency hex
Reproduced in: https: //www.jianshu.com/p/e2b7cbd9c7f7