How can I get my color and set opaque to it?
int myColor = getResources().getColor(R.color.ColorPrimary);
You can use ColorUtils.setAlphaComponent to create a new color value with the same RGB but different alpha. The alpha value needs be from 0 - 255 so it would look something like this:
int color = getResources().getColor(R.color.ColorPrimary);
int color50percent = ColorUtils.setAlphaComponent(color, 128);
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