I'm trying to use Color.parseColor()
on a color resource:
<color name="redish">#FF0000</color>
I've tried this, but it gives me the error Unknown color:
Color.parseColor(Integer.toHexString(context.getResources().getColor(R.color.redish)))
How do I convert the color resource to a String
properly?
Updated answer:
String colorHex = "#" + Integer.toHexString(ContextCompat.getColor(context, R.color.colorPrimary) & 0x00ffffff);
I think you missed #
Color.parseColor("#"+Integer.toHexString(ContextCompat.getColor(context, R.color.redish)))
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