AndroidDeveloperLB / LollipopContactsRecyclerViewFastScroller

A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView
Apache License 2.0
540 stars 95 forks source link

Handling collapse/expand of AppBarLayout in CoordinatorLayout? #9

Closed TheNephilim88 closed 8 years ago

TheNephilim88 commented 8 years ago

Hey,

is it anyhow possible to let appbarlayout collapse or expand depending on how the fastscroller is moved to? (Collapsing when scrolling down the list, expanding when scrolling up)

Usually this will happen in RecyclerView automatically when scrolling up/down.

AndroidDeveloperLB commented 8 years ago

I have no idea. My guess is that it's possible. If you need something, and make a contribution here, I would be happy to accept it into the repo. Just try to make it general enough for other developers. I know I could have done it better, but this is what I needed for a project I worked on.

On Mon, Oct 19, 2015 at 6:54 PM, TheNephilim88 notifications@github.com wrote:

Hey,

is it anyhow possible to let appbarlayout collapse or expand depending on how the fastscroller is moved to? (Collapsing when scrolling down the list, expanding when scrolling up)

Usually this will happen in RecyclerView automatically when scrolling up/down.

— Reply to this email directly or view it on GitHub https://github.com/AndroidDeveloperLB/LollipopContactsRecyclerViewFastScroller/issues/9 .

AndroidDeveloperLB commented 8 years ago

You succeeded?

TheNephilim88 commented 8 years ago

Yes and no.

Calling recyclerView's onTouchEvent in RecyclerViewFastScroller's onTouchEvent will make collapsing and expanding of toolbar work.

Nonetheless its not really perfect. E.g. if you are on bottom of a list (where toolbar is collapsed) and then go up with the fastscroller, then its a bit "jumpy". You know, if you are at index Z and want to go to Y, then toolbar expands, which lead to reposition of the fastscrollbar (the fastscroller-view gets moved a bit down) and so current selected index isnt Y anymore, but for example X. (Dont know if this is understandable ^^)

So if anyone has an idea how to get this smoother, I would be happy to hear about them :)

AndroidDeveloperLB commented 8 years ago

I suggest doing it like on the contacts app : don't change the toolbar at all when dragging the fast-scroller. I know it's not what I did on the sample. It was a quick change and I didn't have enough time to make it work nicely. Sorry about that.