I have created a method to switch between 2 colors every X time.
I called this method on the class constructor (
the class extends View)
The method:
private void setCircleAnimation(){
final int color1 = Color.parseColor("#3399ff");
final int color2 = Color.parseColor("#84c1ff");
circleColor = color1;
postDelayed(new Runnable() {
@Override
public void run() {
circleColor = (circleColor == color1) ? color2 : color1;
invalidate();
postDelayed(this, 300);
}
}, 300);
}
after calling this function on the constructor. I draw the circle like in my code snippet in the question.
Not sure it's the best way to do it, but it works for the moment.
Any other suggestions or corrections are very welcome.
Thanks