How can I get zoom functionality for images?

后端 未结 13 1179
粉色の甜心
粉色の甜心 2020-11-22 02:13

Is there a common way to show a big image and enable the user to zoom in and out and pan the image?

Until now I found two ways:

  1. overwriting ImageView,
13条回答
  •  无人共我
    2020-11-22 02:42

    This is a very late addition to this thread but I've been working on an image view that supports zoom and pan and has a couple of features I haven't found elsewhere. This started out as a way of displaying very large images without causing OutOfMemoryErrors, by subsampling the image when zoomed out and loading higher resolution tiles when zoomed in. It now supports use in a ViewPager, rotation manually or using EXIF information (90° stops), override of selected touch events using OnClickListener or your own GestureDetector or OnTouchListener, subclassing to add overlays, pan while zooming, and fling momentum.

    It's not intended as a general use replacement for ImageView so doesn't extend it, and doesn't support display of images from resources, only assets and external files. It requires SDK 10.

    Source is on GitHub, and there's a sample that illustrates use in a ViewPager.

    https://github.com/davemorrissey/subsampling-scale-image-view

提交回复
热议问题