Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ks...@gmail.com <ks...@gmail.com> #2
Nested scrolling works partially (as per http://b/122818889 ). Let's discuss if we need full support and if so make sure it works.
sa...@gmail.com <sa...@gmail.com> #3
Hi!
What is 'partially' exactly?
How do I see it?
Thanks!
What is 'partially' exactly?
How do I see it?
Thanks!
co...@gmail.com <co...@gmail.com> #4
As of now:
- Nesting scroll views with a scroll direction perpendicular to the ViewPager2's orientation inside ViewPager2 works
- Nesting scroll views with a scroll direction parallel to the ViewPager2's orientation inside ViewPager2 does not work
- Nesting scroll views with a scroll direction perpendicular to the ViewPager2's orientation inside ViewPager2 works
- Nesting scroll views with a scroll direction parallel to the ViewPager2's orientation inside ViewPager2 does not work
co...@gmail.com <co...@gmail.com> #5
Horizontal ViewPager2 not correctly working into a vertical RecyclerView
Set a setNestedScrollingEnabled to the RecyclerView into the ViewPager2 (across reflection) resolves the problem
Set a setNestedScrollingEnabled to the RecyclerView into the ViewPager2 (across reflection) resolves the problem
ez...@gmail.com <ez...@gmail.com> #6
ageevvalentin@gmail.com, could you provide a sample app? I'd like to learn more about the circumstances that cause the problem; putting a clean ViewPager2 inside a clean RecyclerView seems to work fine, so there must be other factors involved.
he...@gmail.com <he...@gmail.com> #7
Added a patch for androidx-master-dev that demos a horizontal ViewPager2 inside a vertical RecyclerView.
Verified that it works correctly on a:
- Nexus 4 emulator with API 17
- Nexus 5X emulator with API 28
- Pixel 2 device with API 29
To reproduce:
- Check out the Android Jetpack source (at commit 256899f482ff85cddfb050f37550be7b5ec927ef) (see steps in [1])
- Apply the patch (`git apply 0001-Add-sample-where-a-horizontal-ViewPager2-is-nested-i.patch`)
- Build and install viewpager2's integration-tests app: `./gradlew viewpager2:integration-tests:testapp:installDebug`
- Run it
Closing the issue for now, but please reopen if you have a minimal reproduction app
[1]https://android.googlesource.com/platform/frameworks/support/+/256899f482ff85cddfb050f37550be7b5ec927ef
Verified that it works correctly on a:
- Nexus 4 emulator with API 17
- Nexus 5X emulator with API 28
- Pixel 2 device with API 29
To reproduce:
- Check out the Android Jetpack source (at commit 256899f482ff85cddfb050f37550be7b5ec927ef) (see steps in [1])
- Apply the patch (`git apply 0001-Add-sample-where-a-horizontal-ViewPager2-is-nested-i.patch`)
- Build and install viewpager2's integration-tests app: `./gradlew viewpager2:integration-tests:testapp:installDebug`
- Run it
Closing the issue for now, but please reopen if you have a minimal reproduction app
[1]
ru...@gmail.com <ru...@gmail.com> #8
Re-opening as requested by a few users. Narrowed down the focus to nested scrolling elements with the same scroll direction.
ru...@gmail.com <ru...@gmail.com> #9
Any progress on this? (only talking about the "same scroll direction" issue)
I searched a lot for workarounds on Google and SO, but it seems no one really found a suitable solution yet.
The thing is that all other VerticalViewPagers out there have other problems that are similarly annoying. Most of them revolve around touch issues like "What's a click and what's a swipe" or "what's the fling threshold to snap to the next page".
So if someone knows of a working sample of VerticalViewPagers, I'd be happy to see a link :)
I searched a lot for workarounds on Google and SO, but it seems no one really found a suitable solution yet.
The thing is that all other VerticalViewPagers out there have other problems that are similarly annoying. Most of them revolve around touch issues like "What's a click and what's a swipe" or "what's the fling threshold to snap to the next page".
So if someone knows of a working sample of VerticalViewPagers, I'd be happy to see a link :)
sj...@gmail.com <sj...@gmail.com> #10
Hi, we're unlikely to address the "same scroll direction" issue before 1.0-Stable as it's likely going to require API changes (so v1.1+).
One possible option for VerticalViewPager with nested scrolling in the same scroll direction is using a RecyclerView implementing NestedScrollingParent + PagerSnapHelper to get snapping.
You'd then have to implement the NestedScrollingParent/Child contract between parent/child RecyclerView instances.
One possible option for VerticalViewPager with nested scrolling in the same scroll direction is using a RecyclerView implementing NestedScrollingParent + PagerSnapHelper to get snapping.
You'd then have to implement the NestedScrollingParent/Child contract between parent/child RecyclerView instances.
st...@gmail.com <st...@gmail.com> #11
Cool, thanks for this quick answer - Both pieces of information are highly appreciated (rough estimate of tackling this as well as giving hint on how to do it).
I will try implementing what you suggested and in case it is readable code, I will post it here as sample project or somthing similar.
I will try implementing what you suggested and in case it is readable code, I will post it here as sample project or somthing similar.
il...@google.com <il...@google.com> #12
That'd be great, much appreciated!
ap...@google.com <ap...@google.com> #13
So...I was too stupid to understand the back and forth and up and down of NestedScrollingParent and NestedScrollingChild/NestedScrollingChild2 and NestedScrollingParentHelper and NestedScrollingChildHelper
But I figured out another way to achieve the same goal. I attached a demo project with the following setup:
1. A parent RecyclerView with PagerSnapHelper:
This vertical RecyclerView has two items/pages.
The upper page is just a simple TextView.
The lower page contains the nested RecyclerView.
Both pages are Fragments if that is of any concern.
2. A PagingLinearLayoutManager:
This is a LinearLayoutManager with the capability to enable/disable scrolling.
It is used for the parent RecyclerView.
3. A OnItemTouchListener:
This is also used for the parent RecyclerView.
It saved the initial y coordinate on ACTION_DOWN
During ACTION_MOVE event, it decides whether the PagingLinearLayoutManager is allowed to scroll (i.e. to switch between pages)
The important parts of the code are commented. Hope this helps someone else!
But I figured out another way to achieve the same goal. I attached a demo project with the following setup:
1. A parent RecyclerView with PagerSnapHelper:
This vertical RecyclerView has two items/pages.
The upper page is just a simple TextView.
The lower page contains the nested RecyclerView.
Both pages are Fragments if that is of any concern.
2. A PagingLinearLayoutManager:
This is a LinearLayoutManager with the capability to enable/disable scrolling.
It is used for the parent RecyclerView.
3. A OnItemTouchListener:
This is also used for the parent RecyclerView.
It saved the initial y coordinate on ACTION_DOWN
During ACTION_MOVE event, it decides whether the PagingLinearLayoutManager is allowed to scroll (i.e. to switch between pages)
The important parts of the code are commented. Hope this helps someone else!
ng...@gmail.com <ng...@gmail.com> #14
Same promble
ba...@gmail.com <ba...@gmail.com> #16
I'm a bit skeptical about the suggested solution from comment#15 that modifies the touch slop.
We're working on a solution that'll work reliably with ViewPager2 1.0. Seehttps://r.android.com/1131083 .
Not finalized at the time of writing, but might help some people already. Notice NestedScrollableHostLayout wrapping [1] a scrollable child.
[1]https://r.android.com/c/platform/frameworks/support/+/1131083/4/viewpager2/integration-tests/testapp/src/main/res/layout/item_horizontal_rvs.xml#55
We're working on a solution that'll work reliably with ViewPager2 1.0. See
Not finalized at the time of writing, but might help some people already. Notice NestedScrollableHostLayout wrapping [1] a scrollable child.
[1]
da...@gmail.com <da...@gmail.com> #17
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 1316417bc87741ea9f739a453eb9e792512c9651
Author: Jelle Fresen <jellefresen@google.com>
Date: Tue Oct 01 16:58:57 2019
Add sample of nested scrolling in ViewPager2
This shows how nested scrolling can be achieved in ViewPager2. Every
child on a page that scrolls in the same direction as ViewPager2 must be
wrapped by a NestedScrollableHostLayout, and one must make sure that the
scrollable child implements canScrollHorizontally/Vertically in order
for this to work.
Bug: 123006042
Test: Manual, run ViewPager2 demo app
Change-Id: I79e24b7668cf7ff5c05c350ea3ab9134dd74b3a4
M viewpager2/integration-tests/testapp/src/main/AndroidManifest.xml
M viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/BrowseActivity.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/NestedScrollableHost.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/ParallelNestedScrollingActivity.kt
A viewpager2/integration-tests/testapp/src/main/res/layout/item_nested_recyclerviews.xml
M viewpager2/integration-tests/testapp/src/main/res/values/colors.xml
M viewpager2/integration-tests/testapp/src/main/res/values/strings.xml
https://android-review.googlesource.com/1131083
https://goto.google.com/android-sha1/1316417bc87741ea9f739a453eb9e792512c9651
Branch: androidx-master-dev
commit 1316417bc87741ea9f739a453eb9e792512c9651
Author: Jelle Fresen <jellefresen@google.com>
Date: Tue Oct 01 16:58:57 2019
Add sample of nested scrolling in ViewPager2
This shows how nested scrolling can be achieved in ViewPager2. Every
child on a page that scrolls in the same direction as ViewPager2 must be
wrapped by a NestedScrollableHostLayout, and one must make sure that the
scrollable child implements canScrollHorizontally/Vertically in order
for this to work.
Bug: 123006042
Test: Manual, run ViewPager2 demo app
Change-Id: I79e24b7668cf7ff5c05c350ea3ab9134dd74b3a4
M viewpager2/integration-tests/testapp/src/main/AndroidManifest.xml
M viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/BrowseActivity.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/NestedScrollableHost.kt
A viewpager2/integration-tests/testapp/src/main/java/androidx/viewpager2/integration/testapp/ParallelNestedScrollingActivity.kt
A viewpager2/integration-tests/testapp/src/main/res/layout/item_nested_recyclerviews.xml
M viewpager2/integration-tests/testapp/src/main/res/values/colors.xml
M viewpager2/integration-tests/testapp/src/main/res/values/strings.xml
de...@gmail.com <de...@gmail.com> #18
We have now merged a working example of ViewPager2 with nested scrollable elements in both: same and orthogonal orientation. See the sample under: https://goo.gle/viewpager2-sample
Notice how the scrollable children of ViewPager2 are wrapped in NestedScrollableHost -- optional for orthogonal elements, required for same-orientation elements.
Notice how the scrollable children of ViewPager2 are wrapped in NestedScrollableHost -- optional for orthogonal elements, required for same-orientation elements.
ra...@gmail.com <ra...@gmail.com> #19
Thank you. That example definitely helps getting that to work. Are there any plans in future to make it work out of the box with with an option to enable that?
de...@gmail.com <de...@gmail.com> #20
More research is needed to decide on the approach, e.g. bundling NestedScrollableHost equivalent in the ViewPager2 package, or other solutions we're considering. Getting feedback on NestedScrollableHost would definitely be useful.
We're keeping this bug open to track effort in the area.
We're keeping this bug open to track effort in the area.
lo...@gmail.com <lo...@gmail.com> #21
I copied the source code for the NestedScrollableHost, and it worked perfectly in my layout. (Horizontal ViewPager2 -> Vertical NestedScrollView -> ConstraintLayout -> NestedScrollableHost -> Horizontal RecyclerView)
It worked just as I would expect it to work. A fling inside of the host flinged the recyclerview to the end. A second fling in the same direction changed the page in the viewpager. I had to lift my finger during a scroll all the way to the end of the recyclerview to get the viewpager to page. Great results.
It worked just as I would expect it to work. A fling inside of the host flinged the recyclerview to the end. A second fling in the same direction changed the page in the viewpager. I had to lift my finger during a scroll all the way to the end of the recyclerview to get the viewpager to page. Great results.
ap...@google.com <ap...@google.com> #22
I ran into (what might be) a similar issue. I have a similar view hierarchy as described in https://issuetracker.google.com/issues/123006042#comment21 . In my use case, a difference might be the horizontal recyclerview is used to show images being queued up for a post. After adding enough images for the recyclerview to be wide enough to scroll the hierarchies should be very similar. However, I noticed that simply tapping in the window after adding the last image to make the recyclerview wide enough to scroll, _then_ scrolling, everything works as expected. Even without the workaround (NestedScrollableHost). AFAICT, the problem seems to be a focus or event suppression issue higher in the view hierarchy. I found this after trying to use NestedScrollableHost and noticing that the class' overridden function wasn't called until after a single tap had occurred. I'm guessing that it's related to ACTION_UP handling, since an initial tap and drag initiates an ACTION_DOWN and it doesn't work.
ap...@google.com <ap...@google.com> #23
Replying to #comment22 , thanks for sharing the observation regarding the behaviour with NestedScrollableHost.
To clarify, does the scrolling functionality work correctly with NestedScrollableHost (both: with 'pre-tap' and directly)?
To clarify, does the scrolling functionality work correctly with NestedScrollableHost (both: with 'pre-tap' and directly)?
ap...@google.com <ap...@google.com> #24
Nope. The pre-scroll tap is required both with and without NestedScrollableHost.
b9...@gmail.com <b9...@gmail.com> #25
Using the layout inspector I'm not able to see a discernible difference in focus state before and after the 'pre-tap' that seems to make everything work for us. Focus state might not be the explanation.
To elaborate a little more, I initially added NestedScrollableHost after #21 reported that it solved the same problem we have. However, through elimination I discovered that the inclusion of NestedScrollableHost didn't seem to make a difference but the 'pre-tap' before attempting to scroll did.
To elaborate a little more, I initially added NestedScrollableHost after #21 reported that it solved the same problem we have. However, through elimination I discovered that the inclusion of NestedScrollableHost didn't seem to make a difference but the 'pre-tap' before attempting to scroll did.
ap...@google.com <ap...@google.com> #26
In trying to simplify the problem, I discovered that the pre-tap issue was caused by a transparent view that was erroneously visible in some cases. Apologies if anyone went down that rabbit trail. However, I can report that I get what seems to be the correct nested scrolling behavior simply with the latest version of viewpager2 and NestedScrollView. Everything is working as expected without NestedScrollableHost.
ViewPager2 (horizontal) > NestedScrollView (vertical) > ConstraintLayout > RecyclerView (horizontal)
ViewPager2 1.0.0
Core (NestedScrollView) 1.1.0
RecyclerView 1.1.0
ViewPager2 (horizontal) > NestedScrollView (vertical) > ConstraintLayout > RecyclerView (horizontal)
ViewPager2 1.0.0
Core (NestedScrollView) 1.1.0
RecyclerView 1.1.0
ap...@google.com <ap...@google.com> #27
Thanks for sharing the findings. It's possible that NestedScrollView (vertical) is doing the same as NestedScrollableHost in this scenario -- will investigate further as we develop an out of the box solution for nested scrolling.
In the meantime, we still recommend NestedScrollableHost as per #comment18 -- unless users have another working solution.
In the meantime, we still recommend NestedScrollableHost as per
ag...@xmartlabs.com <ag...@xmartlabs.com> #28
I have ViewPager2 and Fragment with Slider inside. Both are horizontal. Slider doesn't intercept any events. Is it possible to solve this simply using a flag or something?
sw...@gmail.com <sw...@gmail.com> #29
Re #comment28 , it's difficult to say why no events without seeing a sample. Could you provide one?
Possibly you could override SeekBar's onInterceptTouchEvent similar to
https://issuetracker.google.com/139583428#comment2
Possibly you could override SeekBar's onInterceptTouchEvent similar to
cf...@gmail.com <cf...@gmail.com> #30
Just tried the NestedScrollableHost fix and it worked like a charm for me. My layout is basically ViewPager2 (H) > RecyclerView (V) > RecyclerView (H), and it behaves as #21 described, with or without nestedScrollingEnabled.
The good thing is it also allows my nested RV to recycle properly, compared to wrapping it in a NestedScrollView. Saved my day, thanks.
The good thing is it also allows my nested RV to recycle properly, compared to wrapping it in a NestedScrollView. Saved my day, thanks.
je...@gmail.com <je...@gmail.com> #31
Comment # 30 can you please tell any such option for ViewPager2. I have a ViewPager2 and a webview with horizontal scrolling in Holder now the WebView do not intercept touch and there is I cant find NestedScrollableHost in viewpager2
me...@gmail.com <me...@gmail.com> #33
Hi, I'm having similar issues but this time with a map View.
Only the vertical scrolling of the map works, the horizontal scroll doesn't.
Any lead would be appreciated. Thanks.
Only the vertical scrolling of the map works, the horizontal scroll doesn't.
Any lead would be appreciated. Thanks.
jo...@gmail.com <jo...@gmail.com> #34
Re NestedScrollableHost
directly.
If that doesn't work, check out what it does and follow a similar pattern, the key is wrapping an element in a ViewGroup (e.g. FrameLayout
) and calling requestDisallowInterceptTouchEvent
when appropriate. In case it requires a custom solution like this, share it here so others can benefit.
bl...@gmail.com <bl...@gmail.com> #35
Hi, I have a 3 level navigation in my app and so I created ViewPager2 inside of a ViewPager2 (basically some of the children are Fragments with a FrameLayout that consists of TabLayout and ViewPager2). However scrolling works only on the parent ViewPager, the inner one does not react on scrolling at all. Both have horizontal scrolling. It's very annoying and I can hardly believe this is an intended behaviour, any chance there will be soon a quick and reliable solution, like a flag?
jo...@gmail.com <jo...@gmail.com> #36
Before recommending migration from ViewPager documentation must declare features removed - like nested scroll, scroll interpolators, ability to use Adapter not bound to RecyclerView. It's total pita to restore current functionality provided by ViewPager by default :(
lo...@gmail.com <lo...@gmail.com> #37
I am having this issue with a ConstraintLayout thats uses BottomSheetBehaviour inside the ViewPager2.
I tried the NestedScrollableHost solution but the problem is, if I use a wrapper on this ConstraintLayout, the code will break since the View that is defined as a BottomSheetBehaviour has to be a direct child of CoordinatorLayout (Which is the root view for the ViewPager).
I tried the NestedScrollableHost solution but the problem is, if I use a wrapper on this ConstraintLayout, the code will break since the View that is defined as a BottomSheetBehaviour has to be a direct child of CoordinatorLayout (Which is the root view for the ViewPager).
Description
Version used: 1.0.0-alpha01
Devices/Android versions reproduced on: All
Provide a way to navigate composable screens with animations (slide, fade etc')