Android ViewPager with zoomable ImageView

It's possible, here's how I did it.

My top level layout element is FrameLayout which allows several views to be stacked on top of each other. The FrameLayout has two children: the ViewPager and an ImageView that I'll use for showing zoomed-in picture.

The ImageView is normally hidden. I listen for touch events on pictures inside the ViewPager and based on those, show and hide and pan the ImageView. It works fairly well. I can give more details if need be.


I used the TouchImageView class by Mike Ortiz. It's not perfect. But it's cool because you can drop it in really easily! The double-tap zoom animation can be funny. The pinch zoom can be triggered via double-taps which is weird.

It does work really well if you drop it straight into a ViewPager (via an adapter class). When zoomed in you can freely move left and right without triggering a page change unless you are right on the edge, which is really cool!

https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java