您可以使用这些功能反转颜色...
//color
public static String getHex(int intColor) {
String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
return hexColor;
}
public static String getRGBStringfromHex(String hexColor) {
int color = Color.parseColor(hexColor);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
return red + "," + green + "," + blue;
}
public static int[] getRGBStringtoRGBInt(String splits[]) {
int list[] = new int[3];
list[0]=Integer.parseInt(splits[0]);
list[1]=Integer.parseInt(splits[1]);
list[2]=Integer.parseInt(splits[2]);
return list;
}
public static int getRGBColor(int rgb[]) {
int color = Color.rgb(rgb[0],rgb[1],rgb[2]);
return color;
}
public static String invertedRGBfromRGB(int rgb[]) {
int invertedRed = 255 - rgb[0];
int invertedGreen = 255 - rgb[1];
int invertedBlue = 255 - rgb[2];
return invertedRed + "," + invertedGreen + "," + invertedBlue;
}
public static int getColorFromRGBString(String color) {
ArrayList<Integer> list = new ArrayList<>();
String splits[] = color.split(Pattern.quote(","));
list.add(Integer.parseInt(splits[0]));
list.add(Integer.parseInt(splits[1]));
list.add(Integer.parseInt(splits[2]));
return Color.rgb(list.get(0), list.get(1), list.get(2));
}
Ok now if you convert a int color...
String rgb[]=getRGBStringfromHex(getHex(colorThatWanttoInvert)).split(",");
int desireinvertedcolor=getColorFromRGBString(invertedRGBfromRGB(getRGBStringtoRGBInt(rgb)));
Hope this will help.