Convert CSS hex alpha to Android ARGB

Move the alpha byte from the end of a CSS hex color to the front of an Android color resource. Check the result with a translucent blue test swatch.

2 min read · Updated 2026-11-22

Read the eight-digit hex value in pairs

For a translucent blue, CSS #33669980 splits into red 33, green 66, blue 99 and alpha 80. The alpha byte is hexadecimal: 80 represents 128 out of 255, or about 50% opacity. The other three bytes describe the color before it is composited onto a background.

Write the Android color resource

Move the last pair to the front and keep the red, green and blue pairs in order. Pasting the CSS value unchanged would give Android an alpha of 33 and a red channel of 66. The result would change in both opacity and hue.

Write the Android color resource
XML
<resources>
  <color name="overlay_blue">#80336699</color>
</resources>

Convert a CSS color to Android XML

Verify with a light and a dark surface

Draw the same swatch over white and black on both platforms. If it disappears on both surfaces, check for an alpha of 00. For an opaque control, compare CSS #336699FF with Android #FF336699. If the opaque colors agree but the translucent pair differs, check the backgrounds and any additional view opacity.

Tools featured in this guide

Related formats

Frequently asked questions

How do I convert four-digit CSS hex to Android?

Expand each digit first. CSS #3698 becomes #33669988, which becomes #88336699 in Android XML.

Do six-digit colors need rearranging?

A six-digit hex value specifies opaque red, green and blue in both formats. Only move a pair when the source includes an alpha channel.

Authoritative Specifications & References

More color guides