I ran into the same problem. I solved this using the setDrawingCacheEnabled(true) function. By enabling this option, your canvas view will be cached as a bitmap, so you do not need to call the canvas drawing method every time onDraw() called.
In your custom view designer, you'll need something like this:
public CustomView(Context context) { setDrawingCacheEnabled(true); drawnFlag = false; }
In your onDraw method onDraw you'll need something like this:
public void onDraw(Canvas canvas) { if (! drawnFlag) { canvas.drawPath(...); canvas.drawPath(...); drawnFlag = true; } }
Scrolling on this user view should now be smooth, since we only call drawing methods once.
Andree
source share