Video of my current state,for better understanding of my situation:
video
everything above RecyclerView is inside AppbarLayout
Example of reddit app with similar behavior:
video
Goal:
1-Implement scrolling screen with views in order from top to bottom
a)[several views that need to scroll top until gone, their combined height is several screen sizes]
b)[view that scrolls until it reaches screen top and then sticks there]
c)[RecyсlerView that scrolls beneath view that sticks on screens top] or [ViewPager with fragments containing RecyclerViews]
2-Need it to work both with RecyclerView
and ViewPager
containing fragments
containing RecyclerViews
3-Retain RecyclerViews recycling.
My solution so far:
Coordinator layout, AppBarLayout with appbar_scrolling_view_behavior
and scroll|exitUntilCollapsed
.
Basically placing treating all the views above RecyclerView
as AppBarLayout
and setting attribute scroll|exitUntilCollapsed
to the ones that need scroll off and not setting any scroll attribute to the one that needs to stick.
Explanation:
I wanted to use RecyclerView
with multiple view types
and treat the views
in group a
and b
above as different ViewHolders
and place them at 0
and 1
indexes of the list
supplied to RecyclerView
.
But didn't find any solution on how to make ViewHolder
sticky to top of screen while retaining its clickability (interactivity). All the solutions just draw a view
that you can't communicate in anyway..
In a hurry I used CoordinatorLayout
with AppBarLayout
and set scroll behavior
and scroll flags
Problem:
Scrolling experience is super weird, laggy and with jittering when initial scroll gesture happened inside AppBar
and the second in child view (RecyclerView
or RecyclerView
inside ViewPager
) or in opposite order.
If found custom behavior implementation and it got rid of jitter but there is still some inconsistency in scrolling experience.
QUESTION:
I'm not asking how to fix scroll in my current solution. I'm convinced there is no solution since probably AppbarLayout
should not have height
of a whole screen in the first place. So i did not post video emphasizing scroll bug.
Can I ditch CoordinatorLayout with AppBarLayout completely and achieve intended scroll behfvior?
I spent hours(if not days) looking for ways to implement this T_T.
Please let me know, if you need more info.