Reputation: 1764
What I would like to achieve: Have a ViewPager with TabLayout where each Tab contains a new Fragment that has a RecyclerView layout out horizontally and managed by a FragmentPagerAdapter.
What I am struggling with: The default behaviour is that when you get end of the list on one of the tabs, it switches Tabs and snaps (snapping means if you pull over 50% of the viewport, it jumps to either direction). I want it to free-flow and not to snap. Sort of like how it happens in iOS by default.
I got inspired for this setup by the following two CodePath guide:
How should I approach this problem (preferably without any other libraries)?
Upvotes: 0
Views: 1292
Reputation: 41510
What I would do is use HorizontalScrollView
instead of a ViewPager
. The only caveat is that the view pager sends the lifecycle events to fragments as you scroll between them, whereas for HorizontalScrollView
you will have to add them initially, and then they will be continuously active unless you manually change that. Also you may have an option to not use the fragments and use simple views depending on what you use the fragments for.
I would definitely not override the touch events for the ViewPager
because it does some cleanup when it detects the UP
motion, so just swallowing it is not a correct thing to do.
Upvotes: 1