たとえば、背景が白の場合、テキストの色は黒になります。BG が黒の場合、テキストは白になります。青色の背景、黄色のテキストなど 更新:
// method in MyActivity class
void changeBackgroundColor(int newColor) {
activityLayout.setBackgroundColor(newColor);
int invertingColor = ColorInvertor.invert(newColor);
someTextView.setTextColor(invertingColor);
}
を呼び出すとactivity.changeBackgroundColor(Color.WHITE)、someTextViewテキストの色を黒、つまり などに変更する必要がありColorInvertor.invert(Color.WHITE) == Color.BLACKますColorInvertor.invert(Color.BLACK) == Color.WHITE。