How to Implement "zoom in" and "zoom out" for imageView on Android?

Asked

Viewed 1,029 times

0

I have an Activity where I display an image in the screen size, but I needed to implement the zoom in the image, the same zoom as the Android system that has in all galleries and browsers Android. Does anyone know how to do or which library to implement? Thanks in advance.

1 answer

1

This custom class seems to do what you want:

https://github.com/sephiroth74/ImageViewZoom

Have some ideas on how to implement zero magnification, in this post:

https://stackoverflow.com/questions/6650398/android-imageview-zoom-in-and-zoom-out

The basic forms are:

1) change the "Bounds", ie the rectangle in which the Imageview is drawn. Specifying a very large "Bounds", the image will be drawn enlarged. It nay will take the whole screen if Imageview is inside another View with limited size (the visible part of the image is the "Bounds" of the view it contains). In iOS the equivalent trick works very well (in iOS, it is not "Bounds", it is "frame").

2) use a transform, via setImageMatrix(). Maybe it is the best way because it allows many changes in the image (turn, bend, shift, zoom...) The advantage is that this setImageMatrix() method is specific to Imageview, and acts directly on the image, the "Bounds" of View does not need to be moved and is respected (the image will not overflow to the entire screen if it is enlarged, for example, and there is no need for another view that contains Imageview for "clip", as would be required in method 1).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.