directedition
directedition

Reputation: 11703

Prevent viewpager from moving when multi-touch

I have a ViewPager of images that I want to be able to do some multi-touch work with. This includes pinch-zoom and rotation, both of which are two-finger operations. When I do these actions, the ViewPager starts moving back and forth, and once it gets going, it interrupts whatever action I was in the middle of.

As I want to reserve two-finger gestures for certain operations, I only want the ViewPager to react when a single finger is down. How can I control how many fingers are required for a pager swipe? Or must I disable the ViewPager's built-in gesture detection and write my own?

Upvotes: 0

Views: 1613

Answers (1)

Rotem
Rotem

Reputation: 1492

You will have to override the onTouchEvent method of the ViewPager.

in the MotionEvent that you get, you should check the number of fingers. if it's only 1 then call super, if not do whatever you want with it.

edit: you can check the number of the fingers with event.getPointerCount().

Upvotes: 3

Related Questions