Dealing with Colors in lower Android versions


I’m currently working on a project which requires me to dynamically set the color of certain UI elements to random RGB values.

Unfortunately and surprisingly, handy methods for dealing with colors in Android are only available since API level 26 (Android O). Luckily though, the developer reference specifies, how colors are encoded internally in the Android operating system, so I was able to create a class with the most important color-related (for my use-case) methods which is able to function in lower Android versions as well.

Link to the gist

I hope I can save some of you from headaches by sharing the code. Feel free to reuse as you please 🙂

Happy Hacking!

PS: Is there a way to create Github-like gists with Gitea?

,

One response to “Dealing with Colors in lower Android versions”

  1. […] Dealing with Colors in lower Android versions […]

Leave a Reply

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