Android Custom View - Optimizing Redrawing while Fling
I have a custom view that represents something like a photo-collage.
I need to support the following:
- Fling
- Zoom In
- Zoom Out
Here's what I currently do:
onDraw:
- Look out for the number of images to be drawn.
- Look out for the images to be drawn and their locations and angles
- If the image had been downloaded (from the server), draw it. Otherwise, draw some default image.
onTouch:
action = DOWN: Record X,Y
action = MOVE: Record X,Y;
get the delta; 开发者_JAVA技巧record "new origins" and invalidate the UI.
This will result in redrawing the UI with latest images and coordinates.
However, this has serious performance problems when the images are still not downloaded the user stars flinging.
Is it possible to take a "snapshot" of the "view" and "pan" the "recorded image" during fling? And when the fling is complete, just update the UI with latest images?
精彩评论