About rgba ↔ hex
RGBA adds an alpha channel to RGB for transparency. This tool converts between CSS RGBA, the 8-digit CSS HEX and the Android colour format.
Alpha in different places
- CSS rgba(): alpha is a decimal from 0 (invisible) to 1 (solid).
- CSS 8-digit HEX: #RRGGBBAA, alpha at the end.
- Android: #AARRGGBB, alpha at the start. Mixing these up is a common bug that shows the wrong colour.
The checkerboard preview
A checkerboard pattern behind the swatch lets you see how transparent the colour really is.
A worked example
The colour rgba(36, 73, 184, 0.5) is the blue #2449B8 at half opacity. In CSS 8-digit HEX that is #2449B880, because 0.5 of 255 is about 128, which is 80 in hex. In Android's format the alpha comes first, so it is #802449B8.
Mistakes to avoid
- Pasting a CSS #RRGGBBAA value into an Android resource file. The colours will look wrong because the alpha lands in the wrong place.
- Using transparency for text colours. Semi-transparent text looks different on every background and can fail contrast checks.
- Forgetting that alpha is a number from 0 to 1 in CSS rgba(), not 0 to 100.
