-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[AppBarLayout] Use a uniform way to determine the target scrolling view #3926
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
base: master
Are you sure you want to change the base?
[AppBarLayout] Use a uniform way to determine the target scrolling view #3926
Conversation
This seems like a change/break in the behavior. I think it's reasonable to expect the developer to provide the |
Also, in some cases I believe the doubly nested scrolling works without flickering via the standard CoordinatorLayout APIs (and no liftOnScrollTargetViewId), so this PR could be disabling the current lift on scroll effect for those cases if I understand correctly. |
With that comment I just wanted to say that this PR fixes only the flickering issue, but does not lead to the expected lifting of |
Well, yes, but this is more of an accident than an intended behavior. According to the javadocs, this should only work on material-components-android/lib/java/com/google/android/material/appbar/AppBarLayout.java Lines 101 to 103 in c695802
material-components-android/lib/java/com/google/android/material/appbar/AppBarLayout.java Lines 989 to 990 in c695802
material-components-android/lib/java/com/google/android/material/appbar/AppBarLayout.java Lines 1069 to 1072 in c695802
|
bc46fe8
to
ced300d
Compare
The ScrollingViewBehavior itself should definitely be set on the sibling, but technically CoordinatorLayout supports sending up nested scrolling events up the hierarchy via the behavior's APIs. |
It is, but I don't know what you're getting at. |
I'm trying to understand whether this will cause a regression for some cases where |
In the current implementation you get undefined behavior. Sometimes After applying the PR, -- I think I've started to understand what you're trying to accomplish, but I don't think that's how it's supposed to work, as it goes against the purpose of |
A FrameLayout with appbar_scrolling_view_behavior and a scrolling view inside of it can be scrolled vertically, or at least the "scroll events" get passed up through the CoordinatorLayout Behavior APIs (I believe this is intended by the CoordinatorLayout / nested scrolling architecture). Regardless, I believe we have many pre-existing usages set up that way and it's somewhat common knowledge that appbar_scrolling_view_behavior can be placed on a wrapper <FrameLayout/<Fragment (https://stackoverflow.com/questions/59429919/why-does-my-recyclerview-not-scroll-when-placed-inside-an-appbarlayout). |
Well, it seems the words of a random dude on stackoverflow mean more than the documentation, so I have no choice but to add the desired behavior 😂. |
ced300d
to
b3f08c2
Compare
I just linked that one post as an example of the pre-existing behavior which is somewhat like a contract at this point. I am aware of many internal and external usages that follow that pattern. |
b3f08c2
to
fba8a74
Compare
fba8a74
to
3b13e7c
Compare
3b13e7c
to
04b2bd0
Compare
04b2bd0
to
788a269
Compare
788a269
to
f399ea6
Compare
f399ea6
to
71a498f
Compare
The view that the
AppBarLayout
should use to determine whether it should be lifted is set using thesetLiftOnScrollTargetView
orsetLiftOnScrollTargetViewId
methods. If the target view is not explicitly set, theAppBarLayout
should use a closest scrollable view insideCoordinatorLayout
's child withappbar_scrolling_view_behavior
(due to theCoordinatorLayout
pattern).Unfortunately, the target view is not determined in this way everywhere, so in some cases we may observe incorrect widget state. This PR fixes this issue and unifies the way the target scrolling view is determined.
Fixes #2591, fixes #3925, fixes #4184.