Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used OnTouchListener for nested scrolling in ViewPager2 #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tunjid
Copy link

@tunjid tunjid commented Feb 16, 2020

👋 👋 👋

This PR modifies the NestedScrollableHost to be a View.OnTouchListener rather than a ViewGroup 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 scrollable View, however this is mitigated if this View were a RecyclerView as it could use the RecyclerView.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 middle ViewPager2 had isUserInputEnabled = false and it worked a charm.

@codingjeremy codingjeremy changed the base branch from master to main September 29, 2020 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant