4

I have a ViewPager containing EditText fields (1 per page). When I scroll to the left, the swipe gesture in consumed by the EditText and the page won't change. However when I swipe to the right the swipe gesture is intercepted by the ViewPager as I expect.

How can I force the ViewPager to intercept any horizontal swipe gesture?

znat
  • 13,144
  • 17
  • 71
  • 106

1 Answers1

0

First: that's very odd as I'd expect the ViewPager to consume all horizontal swipes automatically unless you are overriding some gesture related method. For example, I've used a MapFragment within a ViewPager before and unless I scrolled up on the map first, the horizontal swipes would always trigger the view pager.

Second, I don't think you can make your ViewPager more inclusive than it already is in picking up x-direction swipes. What I would do instead is simply add a gesture listener to your edittext. If you do this, you could use an Inteface to the ViewPager activity to trigger the page to change on swipe.

Btw this should also still allow clicks on the EditText itself so you could still use it as intended.

Community
  • 1
  • 1
Rarw
  • 7,645
  • 3
  • 28
  • 46