0
votes

I'm facing a problem regarding a ViewPager that hosts multiple fragments.

The ViewPager's horizontal swipe is working very well when I'm swipping left/right. The thing is I have a menu that should appear if I click anywhere in a fragment. The problem is when I'm adding an onClick() event inside the fragment, the ViewPager swiping become particularly inaccurate, and it's hard to swipe between fragments by now. Indeed, the onClick() event is fired instead of detecting a swipe.

Then, I have a lot of false/positive when I'm trying to switch between fragments.

Do you have an idea of workaround for this? Maybe I can intercept the touch event before it reaches the fragment when a beginning of swipe is detected?

I hope my question is enough clear for you, don't hesitate to ask details.

Regards,

2
Complete shot in the dark here: try using android:maxLines="1" instead of android:singleLine="true". If that doesn't apply to whatever you're doing, forget I said anything.Alex Lockwood

2 Answers

1
votes

It happened on me when i have TextViews inside ViewPager Fragment with

android:gravity="center_horizontal"
android:singleLine="true"

I had to change singleLIne to android:maxLines="1"

0
votes

I often use ViewPager with Jake Wharton's ViewPager Indicator. I have to see I never encounter the problem you said.

The viewpager has a good implementation to identify click gesture and swiping gesture.

Maybe you'd better provide some code.