davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.55k stars 548 forks source link

Scroll to position of header #684

Closed alexanderhudym closed 5 years ago

alexanderhudym commented 5 years ago

I'm using 5.1.0 version of this library. When i want to scroll to header i use something like this rv.scrollToPosition(adapter.getGlobalPositionOf()) it does not scroll to needed position required header at bottom of view so i need use something like this rv.scrollToPosition(adapter.getGlobalPositionOf() + 5) to header appears at top Sorry for my bad english!

davideas commented 5 years ago

@alexanderhudym, try to use the adapter feature to scroll, it is asynchronous to give a small amount of time at the LayoutManager to complete the layout and only after smooth-scroll.

alexanderhudym commented 5 years ago

I've found solution! I use it:
linearLayoutManager.scrollToPositionWithOffset(adapter.getGlobalPositionOf(Item()), 0) scrollToPosition method of recycler view works like a: linearLayoutManager.scrollToPositionWithOffset(adapter.getGlobalPositionOf(Item()), rv.height)