- Is it a good programming practice to call
As per my understanding, calling
onDraw() is expensive and is not required if there is no change to the canvas.
invalidate()equivalent to an asynchronous version of
As per my understanding, they are equivalent. Correct me if I am wrong. Thank you.
invalidate() if your data has changed and needs to be redrawn. You generally don’t do this in
onDraw(), because at that point you are drawing your current data, not changing it. (There are some cases where you may want to do this, such as for running animations, but generally I would recommend instead using a delayed message to control your own timing of the updates.)