Search code examples
androidandroid-layoutcolorshexandroid-canvas

Hex colors in Android are sometimes eight digits. How? What is the difference between #FFFFFF and #FFFFFF00?


I sometimes have seen in examples where the coloring in Android is done as #FF191919. I mean an eight-digit hex number. But it should only be a six-digit number. How are they related?

If I want to convert a six-digit number to a eight-digit number, how can I do it? I mean convert #424242 to a eight-digit number coloring? What are the the details?


Solution

  • The extra two digits are used to define the colors' transparency, or alpha channel.

    Android uses the ARGB format (or AARRGGBB as you use in your example).

    For more (Android-specific) information, take a look at the Color documentation.