1

The color white, as far as I know is defined as

#ffffff

but android defines it this way

#ffffffff

why the 2 extra f?

Thanks

edmond
  • 833
  • 3
  • 13
  • 31
  • 6 hex digits means it's RGB, 8 digits means it's ARGB – sharp Apr 26 '16 at 10:04
  • 2
    Possible duplicate of [Hex Colors in Android are some times 8 digits. How?](http://stackoverflow.com/questions/6909896/hex-colors-in-android-are-some-times-8-digits-how) – Yoann Hercouet Apr 26 '16 at 10:10

2 Answers2

3

Colour codes are usually defined in either 3, 6, or 8 characters.

#FFFFFF

means that it is in RGB format. However, you can also have

#FFFFFFFF

is in ARGB format, which means that the first two characters represent the alpha value. In other words, the first two characters represent the opacity.

Have a look at this answer for a Java method to calculate the alpha values.

Community
  • 1
  • 1
Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
  • @camelCaseCoder is there a formula to calculate the first two characters depending of what opacity I would like to have? amdroid suggest to use 87% for primary text and 54% for secondary text and so on – edmond Apr 26 '16 at 10:11
  • @edmond have a look at my answer for the table – camelCaseCoder Apr 26 '16 at 10:12
  • 2
    @edmond See my update (look at [this answer](http://stackoverflow.com/a/27813407/4230345)) for a Java method / formula. – Farbod Salamat-Zadeh Apr 26 '16 at 10:16
1

The first two places define the transparency/opacity of the color.

Here's a correct table of percentages to hex values. E.g. for 50% white you'd use #80FFFFFF.

  • 100% — FF
  • 95% — F2
  • 90% — E6
  • 85% — D9
  • 80% — CC
  • 75% — BF
  • 70% — B3
  • 65% — A6
  • 60% — 99
  • 55% — 8C
  • 50% — 80
  • 45% — 73
  • 40% — 66
  • 35% — 59
  • 30% — 4D
  • 25% — 40
  • 20% — 33
  • 15% — 26
  • 10% — 1A
  • 5% — 0D
  • 0% — 00

Source

Community
  • 1
  • 1
camelCaseCoder
  • 1,447
  • 19
  • 32