6

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...?

Sri
  • 159
  • 1
  • 6
  • 14

2 Answers2

10

Try this:

Color.parseColor("#FF0000")

int color = 0xFFFF0000;

Hope this may help you!

Krupa Patel
  • 3,309
  • 3
  • 23
  • 28
1

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>
Robert
  • 1,272
  • 4
  • 21
  • 40