user4386126
user4386126

Reputation: 1245

Handle ViewPager swipe inside Navigation Drawer

I am using ViewPager inside my Navigation Drawer and am encountering an issue when I want to swipe to next tab in ViewPager. Swiping works in direction which opens Navigation Drawer but doesn't work in direction which closes Navigation drawer.

That means I can normally swipe to ViewPager pages to "right" direction but when I want to swipe to the "left", NavigationDrawer intercepts touch events and closes itself.

I would still like to have ability for navigation drawer to close if user swipes on content which doesn't have horizontal scroll. How can I accomplish something like this? Thank you.

Upvotes: 3

Views: 951

Answers (1)

Elltz
Elltz

Reputation: 10869

use View.requestDisallowInterceptTouchEvent(true); when you do not want your ViewPager to close, call this View.requestDisallowInterceptTouchEvent(false); immediately after Action_Up.

What it does is it prevents the parent from listening or intercepting the touch event.

Upvotes: 3

Related Questions