Is there any way to call colors from colors.xml in java? I have created an editor and i want use those colors which i have already defined in colors.xml from java how can i do this ?
To get a color as an int, use the following:
int myColor = getResources().getColor(R.color.myColor);
Then, to use this color in a TextView, use the following:
myTextView.setTextColor(myColor);
Use this:
getResources().getColor(R.color.your_color);
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