我想改變色盲選項菜單中的顏色,我想有兩個strings.xml文件,並在按鈕按下時在它們之間切換。 ImageButton
改變顏色在strings.xml中聲明的正確方法是什麼?如何更改android應用程序中的顏色?
final Switch colorsChange= (Switch) findViewById(R.id.switch_colors);
colorsChange.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// Color blind friendly colors here
} else {
// Normal RGB colors here
getResources().getColor(R.color.defaultColors);
}
}
});
我想繼續跨越如果可能的話所有活動
發佈您的代碼,請 –
發佈添加你想要的顏色到你的資源
android:onClick="methodName"
顏色的兩種變化'如果(器isChecked){// 色盲友好的色彩在這裏 ImageButton.setBackgroundColor(Color.parseColor(的getString(R.string.red)) }其他{ //正常RGB顏色在這裏 getResources()。getColor(R.color.defaultColors); }' –