简体   繁体   中英

colors code in android are different

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

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.

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

Here's a correct table of percentages to hex values. Eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM