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

2

2 Answers 2

10

Try this:

Color.parseColor("#FF0000")

int color = 0xFFFF0000;

Hope this may help you!

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.