问题
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; 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?
来源:https://stackoverflow.com/questions/2764371/android-custom-view-optimizing-redrawing-while-fling