-1

Possible Duplicate:
How to implement zoom, pan and drag on Viewpager in android?

I have implemented a viewpager which contains different views inside it like, imageview then videoview and etc. What I am trying to implement is pinch zoom, pan and drag on the viewpager so that irrespective of any specific view inside viewpager. I can perform pinch zoom, pan and drag on it.

Another challenge is by default viewpager has a event for touch via which it performs switching of views inside it. If anybody went through this or have idea about this case, please advise me.

Community
  • 1
  • 1
Devavrata
  • 301
  • 1
  • 3
  • 12

1 Answers1

1

We may have gone through something similar. We have a ViewPager the contains layouts with ImageViews. The ImageViews support pan, pinch, drag, etc. Our challenge was how to determine when the ViewPager should scroll vs an pan/drag on an ImageView.

You can see an example of the behavior in our application, Brilliance: 500px Image Viewer.

Our solution was to override onTouchEvent and onInterceptTouchEvent in the ViewPager class. The new methods ask, via an intermediary, if the event should be handled by the current item or by the ViewPager itself.

For example, if a user swipes a zoomed image, the image will pan. If the user swipes a normal image, the ViewPager will scroll the next or previous item.

user1509445
  • 351
  • 1
  • 3
  • 5