Reputation: 5506
I've a Layout which has a bg color customized by user. User fills 4 values. R-G-B-Alpha
But, I've seen that the method to set the color in a layout, doesnt accept 4 values.
setBackgroundColor()
just accepts int value.
I've searched for a java parser, from RGBA to HEX but I couldn't find any.
Do you know guys where could I find one?
Thanks.
Upvotes: 3
Views: 13451
Reputation: 3703
write color code in color.xml in values folder-
<resources>
<color name="white">#FFFFFFFF</color>
<color name="black">#FF000000</color>
<color name="red">#FFFF0000</color>
<color name="blue">#FF0000FF</color>
then in your code set layout background
LinearLayout ll=find(...);
ll.setBackgroundResource(R.color.white);
Upvotes: -4
Reputation: 15720
Try this one.
setBackgroundColor(Color.argb(a_int, r_int, g_int, b_int));
Upvotes: 14