How to convert Color.RED code to integer color values ​​in Android Java?

In my Android projects, I set the color for PieChart, like this

public static int[] COLORS = new int[] { Color.GREEN, Color.BLUE };

That import android.graphics.Color; has only a few colors around 10. I need more color, so I tried to set as a whole, but didn't work. Color.alpha(16777184)for light yellow. Does this code not work? how to set the integer color value here ...?

+4
source share
2 answers

Try the following:

Color.parseColor("#FF0000")

int color = 0xFFFF0000;

Hope this helps you!

+6
source

XML . Kruba Patel HEX , .

XML- R.color.color_name, , R.color.color_name int:)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color
        name="color_name"
        >hex_color</color>
</resources>
+1

All Articles