ZoomImageView
is a ImageView
implementation that can control pan and zoom over its Drawable or Bitmap.
Use it by simply declaring it in your XML layout:
<com.otaliastudios.zoom.ZoomImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical|horizontal"
app:transformation="centerInside"
app:transformationGravity="auto"
app:alignment="center"
app:overScrollHorizontal="true"
app:overScrollVertical="true"
app:overPinchable="true"
app:horizontalPanEnabled="true"
app:verticalPanEnabled="true"
app:zoomEnabled="true"
app:flingEnabled="true"
app:scrollEnabled="true"
app:oneFingerScrollEnabled="true"
app:twoFingersScrollEnabled="true"
app:threeFingersScrollEnabled="true"
app:minZoom="0.7"
app:minZoomType="zoom"
app:maxZoom="2.5"
app:maxZoomType="zoom"
app:animationDuration="280"/>
There is nothing surprising going on. Just call setImageDrawable()
and you are done.
Presumably ZoomImageView won’t work if:
There are lots of libraries on this topic and this is not necessarily better, yet it is a natural implementations of the zoom engine. It is fast, lightweight and simple.
The zoom image view will forward all API calls to the internal engine: see zoom, pan
and low level engine documentation. You can also get the backing engine using zoomImageView.getEngine()
.
zoomImageView.panTo(x, y, true); // Shorthand for zoomImageView.getEngine().panTo(x, y, true)
zoomImageView.panBy(deltaX, deltaY, true);
zoomImageView.zoomTo(zoom, true);
zoomImageView.zoomBy(factor, true);
zoomImageView.realZoomTo(realZoom, true);
zoomImageView.moveTo(zoom, x, y, true);