I’ve created an activity that calls a DrawView extends View, I draw on a Canvas something like a binary tree. The canvas size is greater than the screen size, and the onDraw function draws all the canvas, not only the visible part of it. I’ve added an horizontal and a vertical scrollView, and obviously onDraw is called again and again to refresh the view.
I was wondering if I can draw the canvas on an image (a bitmap or something like that) using that image to show the tree, without the need to recall the onDraw function.
If I can’t do this, what can I do in order to get a faster view?
I’ve created an activity that calls a DrawView extends View, I draw on a
Share
Technically the canvas draws on a Bitmap. So it’s actually the Bitmap that’s bigger than the screen. Why are you making the Bitmap bigger than the screen? Bigger Bitmaps = more memory usage – which could slow things down a bit. You only really draw within the clipped bounds of the screen – you may think you’re drawing off screen but you’re not. Drawing on another Bitmap won’t help you – you’re already doing that. Without looking at your code you could try:
invalidate(rect)which only repaints what has changed