I have an android game. I change the color scheme on touch. The code is:
if(rect_dark.contains(x, y)) {
isdark = !isdark;
invalidate();
}
Then in my onDraw method:
if(isdark){
this.setBackgroundColor(getResources().getColor(R.color.black_color));
} else{
this.setBackgroundColor(getResources().getColor(R.color.light_color));
}
if(isdark){
mScorePaint.setColor(getResources().getColor(R.color.light_color));
} else{
mScorePaint.setColor(getResources().getColor(R.color.black_color));
}
So, when I press the button the changings of color are not synchronized. At first the background color is changed and then the text color. Eyes see that.
How to deal this problem? Thanks for all the answers.