Search code examples
androiduser-interfacepinchzoom

Scrollable/zoomable view in Android


In iOS, since 2.0 in 2008, there's the UIScrollView class to provide a view that the user can pinch zoom and drag around.

Is there an equivalent class in Android Jellybean and up?

I've found some questions here, where the answer is to make a custom class containing all the programming needed to detect the pinching and dragging, and then adjust an ImageView accordingly.

Is this really the way to go for such a basic touch screen function?


Solution

  • I suggest you to try the one of the following libraries, depending on what kind of content you need to handle:

    1. Generic Zoomable View: https://github.com/Polidea/android-zoom-view

    Just wrap you content with an instance of ZoomView:

    //...
    ZoomView zoomView zoomView = new ZoomView(getActivity());
    zoomView.addView(contentInflatedView);
    //add zoomView to your layout...
    

    2. Zoomable ImageView: https://github.com/chrisbanes/PhotoView