Used OnTouchListener for nested scrolling in ViewPager2 #112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋 👋 👋
This PR modifies the NestedScrollableHost to be a
View.OnTouchListener
rather than aViewGroup
that houses the nested scrolling child.I don't think this is a better implementation per se, just more of a different one. I'm mostly curious about the design decisions that led to opting for nesting the scrollable child rather than using the
View.OnTouchListener
.Off the top of my head, I can see the
View.onTouchListener
is a bit intrusive and limits custom touch interception on the nested scrollableView
, however this is mitigated if thisView
were aRecyclerView
as it could use theRecyclerView.OnItemTouchListener
instead, which would be perfect for this example.FWIW, this solution worked with nested ViewPagers, i.e I had
ViewPager2
->ViewPager2
->HorizontalScrollView
where the middleViewPager2
hadisUserInputEnabled = false
and it worked a charm.