Understanding Colors on Android (Six Characters)

Understanding colors on Android (six characters)

If you provide 6 hex digits, that means RGB (2 hex digits for each value of red, green and blue).

If you provide 8 hex digits, it's an ARGB (2 hex digits for each value of alpha, red, green and blue respectively).

So by removing the final 55 you're changing from A=B4, R=55, G=55, B=55 (a mostly transparent grey), to R=B4, G=55, B=55 (a fully-non-transparent dusky pinky).

See the "Color" documentation for the supported formats.

Hex transparency in colors

Here's a correct table of percentages to hex values for opacity. E.g. for 50% white you'd use #80FFFFFF. To think in terms of transparency instead, flip the order of the percentages (more opaque = less transparent).































































































%Hex
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

How to get a Color from hexadecimal Color String

Try Color class method:

public static int parseColor (String colorString)

From Android documentation:

Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'

AndroidX: String.toColorInt()

What are the Material Design dark theme colors?

This is the latest version of colors:

This page in the official material design website is dedicated to dark theme (including its colors). Here is the colors:

Dark theme colors

The image below compares Light and Dark theme colors (Light colors on the left side, Dark colors on the right):

Light and Dark theme colors

Image credits: official material design website

Android Q dark mode changes color of drawable form white to gray

Try calling setForceDarkAllowed(false) on the views you want to remain the same when dark mode is enabled.
See the docs



Related Topics



Leave a reply



Submit