Android Surfaceview Displays Blank When Locked Canvas Is Not Null
I'm creating a simple game using a view which extends a SurfaceView and using a thread to draw images on the SurfaceView. The game will have its own thread (game engine) to draw an
Solution 1:
I know this is an old post but just in case it helps someone out there.
I had this same problem, almost identical code to yours, and found that all I needed to do was call postInvalidate()
from my overridden onDraw(Canvas canvas)
method in my SurfaceView.
This is my code:
@Override
protected void onDraw(Canvas canvas)
{
mPaperPlaneImage.draw(canvas);
postInvalidate();
}
Solution 2:
You need to call onDraw(Canvas canvas) to render instead of your render() because onDraw works with hardware screen buffers. Check the second example How can I use the animation framework inside the canvas?
Post a Comment for "Android Surfaceview Displays Blank When Locked Canvas Is Not Null"