例如,如果背景为白色,则文字颜色将为黑色。如果BG是黑色的,文本将是白色的。蓝BG,黄文等 更新:如何在TextView中设置文本的自动翻转颜色?
// 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
等
抱歉,这是一个程序员论坛,所以你不可能在这里得到应用程序使用的答案。请尝试[超级用户论坛](http://superuser.com/),其中提供了有关应用程序和操作系统使用的帮助。 –
你有试过什么吗? – RobinHood
会给更多的代码请 –