例如,如果背景爲白色,則文字顏色將爲黑色。如果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
會給更多的代碼請 –