Apply ARGB color to a textview programmatically

dfetter88 picture dfetter88 · Jul 16, 2010 · Viewed 15.9k times · Source

I'm currently using something like: TextView.SetBackgroundColor(Color.WHITE); in my java code. I'd like to be able to add some transparancy to the textview through the java... This is easy to do in the XML via #AARRGGBB format, but I have not found a way to accomplish this programmatically.

Answer

eldarerathis picture eldarerathis · Jul 16, 2010
TextView.SetBackgroundColor(Color.argb(a_int, r_int, g_int, b_int));

Or:

TextView.SetBackgroundColor(Color.parseColor("#AARRGGBB"));