In my android projects i set color for PieChart like this
public static int[] COLORS = new int[] { Color.GREEN, Color.BLUE };
In that import android.graphics.Color; have only few colors around 10. I need more color so i tried to set as integer but didn't working. Color.alpha(16777184)
for light yello color. this code is not working ? how to set here as integer value of color...?
To set the values from RGB you can do so by: Color myColour = new Color(red, green, blue); int rgb = myColour. getRGB(); //Change the pixel at (x,y) ti rgb value image. setRGB(x, y, rgb);
The four components of a color int are encoded in the following way: int color = (A & 0xff) << 24 | (R & 0xff) << 16 | (G & 0xff) << 8 | (B & 0xff);
I'd more preffer to use XML file. Suggested solution by Kruba Patel will in fact force developer to remember HEX of color and also redundante of code.
Here XML resource example just call R.color.color_name
please note that R.color.color_name will return generated int value :)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name="color_name"
>hex_color</color>
</resources>
Try this:
Color.parseColor("#FF0000")
int color = 0xFFFF0000;
Hope this may help you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With