ProBuilder Advanced
July 16, 2017

Android Hexadecimal Color Transparency Chart

I was working on a daily quote app recently and was tasked with figuring out how to achieve transparency on a TextView with a background color.  In most situations there would be a simple transparency or opacity attribute that I could set to my desired setting.  This is not the case when developing in Android Studio.  Thanks to some clever searching I stumbled upon a post on Stack Overflow that contained all the information I needed:

Transparency %  Code
 100% 00
 90% 1A
 80% 33
 70% 4D
 60% 66
 50% 80
 40% 99
 30% B3
 20% CC
 10% E6
0% FF

Awesome!  Now all I had to do was prepend the given code to my color definition.  I ended up with the following color definition:

<color name="colorBlackSemiTrans">#CC000000</color>

Now you can simply set your TextView background value like so:

android:background="@color/colorBlackSemiTrans"

 

Happy developing!

Mike Wojcik
Mike Wojcik
WordPress Expert, Web & Game Developer, Superhero & Dad. Mike has been involved in software and web development for over a decade and has experience that covers a wide range of different areas ranging from server deployment and maintenance to project management to full scale website development from scratch.

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz