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.
Asked
Active
Viewed 1.7k times
19

dfetter88
- 5,381
- 13
- 44
- 55
2 Answers
45
TextView.SetBackgroundColor(Color.argb(a_int, r_int, g_int, b_int));
Or:
TextView.SetBackgroundColor(Color.parseColor("#AARRGGBB"));

eldarerathis
- 35,455
- 10
- 90
- 93
-
java.lang.NumberFormatException: Invalid long: "AARRGGBB" – Aug 03 '15 at 16:08
-
2@delive: `ARGB` is a placeholder, it represents Alpha, Red, Green, and Blue. The function expects hexadecimal numbers, two digits for each color channel. If you're having trouble with your code, it would probably be best to ask a new question. That error alone isn't enough context, but it makes it appear as though you literally passed in the string `AARRGGBB`, which is not a valid hexadecimal color. – eldarerathis Aug 03 '15 at 17:32
-
I thought it wasn't working, just to realize I'd set a value too low for the _alpha_. – FirstOne Aug 31 '18 at 13:11
-
Each of the values ranges from 0 - 255. (Including alpha) – SUR4IDE Aug 01 '22 at 22:35