I implement a view by myself, the onDraw method of the view is called repeatedly. This will cause a serious performance problem. The code is so complex that I can’t paste here. Anyone can tell me some possible reasons? I haven’t touch the view by my finger.
Share
One reason would be that your
onDrawmethod is calling some method that (perhaps indirectly) invalidates the view. Another possibility is something completely unrelated in your program is causing the repaints. Try this experiment: comment out your drawing code and substitute something really simple, such as a simple line draw, just to show that it’s working. If the repeated drawing goes away, then it’s something in youronDrawcode. Just start restoring the current code a bit at a time until the problem reappears and then you can track it down.If the problem doesn’t go away when you try the experiment, then look somewhere else in your code for something (perhaps a worker thread?) that is invalidating your view.