Piotr Chojnacki
Piotr Chojnacki

Reputation: 6857

How to prevent onTouchEvent() method to be called for more than one views at once?

I'm using a ViewPager and in one of my pages I have a View with overriden onTouchEvent() method.

Now when user moves his finger on a screen, onTouchEvent() of my View is being called, but also ViewPager is moving a page to left or right. I'd like to prevent somehow ViewPager from calling it's onTouchEvent() method IF a user is touching my View's area. Is it possible?

Upvotes: 2

Views: 1283

Answers (1)

Anup Cowkur
Anup Cowkur

Reputation: 20563

ViewPager will by default intercept all touch events. In fact, if you put anything inside anything else that scrolls, the container will intercept the touch event. You can override this behavior in certain cases. There is a similar problem with a solution here that might help you:

ViewPager intercepts all x-axis onTouch events. How to disable?

Upvotes: 1

Related Questions