How do I create a color int from alpha, red, green, blue values (all from 0-255)?
I need this color int to set a view's background color.
I tried this:
protected int colorStringToColor(String colorString){ // whereas colorString is i.e. "214+13+22+255" or "214+13+22+85"
String[] comps = colorString.split("\\+");
int myColor = 0;
if(comps.length == 3){
int a = 255;
int r = Integer.parseInt(comps[0]);
int g = Integer.parseInt(comps[1]);
int b = Integer.parseInt(comps[2]);
myColor = Color.argb(a, r, g, b);
} else if (comps.length == 4){
int a = Integer.parseInt(comps[3]);
int r = Integer.parseInt(comps[0]);
int g = Integer.parseInt(comps[1]);
int b = Integer.parseInt(comps[2]);
myColor = Color.argb(a, r, g, b);
}
return myColor;
}
However, when I use the result for setting a views background color, both example colorString are of the same red???
Thanks a lot.