Android Custom View - Optimizing Redrawing while Fling

两盒软妹~` 提交于 2019-12-24 07:07:28

问题


I have a custom view that represents something like a photo-collage.

I need to support the following:

  1. Fling
  2. Zoom In
  3. Zoom Out

Here's what I currently do:

onDraw:

  1. Look out for the number of images to be drawn.
  2. Look out for the images to be drawn and their locations and angles
  3. If the image had been downloaded (from the server), draw it. Otherwise, draw some default image.

onTouch:

  1. action = DOWN: Record X,Y
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!