Android UI

Color Opacity Using XML In Android

It is very easy to give color opacity effect in android. Best way to add transparency by percentage is by using alpha channel in android i,e 8 digit ARGB values, Alpha-Red-Green-Blue hexadecimal. Which is appending a 2 letter value to hexa code of a color. If you know alpha codes for transparency then you don’t have to create separate graphics for achieving such transparency effect. It is time saving and maintainable.

Transparency is controlled by the alpha channel (AA). Maximal value (255 dec, FF hex) means fully opaque. Minimum value (0 dec, 00 hex) means fully transparent. Values in between are semi-transparent, i.e. the color is mixed with the background color.

To get a fully transparent color set the alpha to zero. RR, GG and BB are irrelevant in this case because no color will be visible. This means #00FFFFFF (“transparent White”) is the same color as #00F0F8FF (“transparent AliceBlue”). To keep it simple one chooses black (#00000000) or white (#00FFFFFF) if the color does not matter.

Alpha Channel Chart

Alpha Channel In Android

About author

Rojer is a programmer by profession, but he likes to research new things and is also interested in writing. Devdeeds is his blog, where he writes all the blog posts related to technology, gadgets, mobile apps, games, and related content.

Leave a Reply

Your email address will not be published. Required fields are marked *