First you have to get the color in decimal
format with a formula:
For the TextView color:
int colorText = textView.getCurrentTextColor();
int colorDecimalText = (colorText)+(16777215+1);
To obtain the decimal of some color that is in resources (colors.xml):
int colorRecurso = getResources().getColor(R.color.tuColor);
int colorDecimalRecurso = (colorRecurso)+(16777215+1);
In this way you get the color in decimal
that you can
convert to Hex
on websites like: link
Hex
is the color format in colors.xml.
The formula + (16777215 + 1) is used because
takes the white color base, which is subtracted from the first int.
Or use this code to convert it to Hex:
String hexColorText = "#" + Integer.toHexString(colorText).substring(2);
String hexColorRec = "#" + Integer.toHexString(colorRecurso).substring(2);
To compare in decimal
:
if(colorDecimalText == colorDecimalRecurso){
... tu código
}
To compare as String
(Hex):
if(hexColorText.equals(hexColorRec)){
... tu código
}