I am trying to implement a Gallery of images using ViewPager. Also, to implement zoom feature in that, I am using TouchImageView from github. I have also tried using ZoomableImageView.
But, the problem is, if I zoom the image & if I scroll the image , then instead of image, ViewPager
is getting scrolled & next view of ViewPager
is getting loaded.
If I zoom the image then if I scroll that, then image has to move instead of ViewPager
ViewPager's next view has to load only if reach the end of the zoomed image. How to do that?
I am not able to find that.If I touch & drag the image diagonally, only then image is getting moved. or else ViewPager's drag is getting invoked.
ps: this is not duplicate. Zooming is done. But the problem is after image zooming.
I have finally found the Subsampling Scale Image View library, which works even with standard ViewPager from Android Support Package without any customisations.
Yes I too had the same problem not with TouchImageView.
Too solved the problem what i did is disabled the ViewPager when my view is getting the focus.
so in TouchImageView implement your listener to trigger an event whether its zooming or dragging.
set listener to your view object in your Activity. So when those event occur just disable the view Pager.
Note: you will also need a mouse up event to enable the viewpager.
EDITED
This will work only for Zoom, so for ViewPager to swipe pages you should zoom back to original.
Add these code to your TouchImageView
BETTER SOLUTION
We could achieve this without extending ViewPager to a new Class by using the method given below.
And with this we could swipe without zooming out to original position as we see in Gallery and many other apps.
If someone have a horizontal viewpager, is important change @kirit-vaghela code:
To
So the adapter's gonna change the picture only when is 1.0
I got it to work by adding this code: