Open awenger opened 8 years ago
This is an interesting problem. I think that what you wrote about nested scrolling makes a perfect starting point. One should probably look into how RecyclerView
handles various scroll methods internally and move to another method if scrollToPosition
doesn't work as expected. Filing a RecyclerView
bug in Google would tell us if this is intended or not. Anyway this has to be fixed. The problem is that I currently have no time for maintaining the lib, so if you wanted to contribute, investigate this issue and post a PR, that would be great.
Also, if you decide to file a bug to Google, reference it here, please.
I tried to use this library with a
RecyclerView
inside of aCoordinatorLayout
that also contains aAppBarLayout
with aToolbar
that usesapp:layout_scrollFlags="scroll|enterAlways|snap"
:This has the following problems:
FastScroller
isn't collapsing/expanding theAppBarLayout
FastScroller
to scroll to the last entry in the list if theAppBarLayout
is expandedFastScroller
are not visible (I quick fixed this problem with usingmarginTop
/marginBottom
for theFastScroller
)It seems that
RecyclerView
doesn't handle Nested Scrolling if you scroll withscrollToPosition
. Sadly I couldn't find any proper documentation how Nested Scrolling is supposed to work. So I can't say if this is a bug inRecyclerView
or this is supposed to be handled by the scroll initiator. But I think it is possible to handle it with:ViewCompat.startNestedScroll
ViewCompat.dispatchNestedPreScroll
RecyclerView.scrollBy
ViewCompat.dispatchNestedScroll
ViewCompat.stopNestedScroll
This snippet demonstrates a way that let's the
RecyclerView
scroll by 300px while also collapsing theAppBarLayout
. However I don't know this is the proper way to do it:I'm not sure if it is possible to fix this problem with the current approach in this lib to scroll with
scrollToPosition
.