5.x | Smooth Layout Managers - davideas/FlexibleAdapter GitHub Wiki
The UI extension library comes with 3 Layout Managers:
- SmoothScrollLinearLayoutManager
- SmoothScrollGridLayoutManager
- SmoothScrollStaggeredLayoutManager
As their name say, they provide the smooth scroll, used internally for special use cases, such as, expand an item to show the sub items and also in addItemWithDelay()
operation.
Classes location :eyeglasses:
eu.davidea.flexibleadapter.common
|_ SmoothScrollGridLayoutManager
|_ SmoothScrollLinearLayoutManager
|_ SmoothScrollStaggeredLayoutManager
|_ TopSnappedSmoothScroller
Usage
If you want use them, I recommend to execute the scroll in post or postDelayed. The reason is to allow the LayoutManager to complete its process so that scrolling animation doesnt't raise exception of inconsistency.
mRecyclerView.post(new Runnable() {
@Override
public void run() {
mRecyclerView.smoothScrollToPosition(position);
}
});
From 5.0.0-b8, the static field TopSnappedSmoothScroller.MILLISECONDS_PER_INCH
is public
, so you can customize the scrolling time: value must be assigned before the LayoutManager creation.
:warning: Warning: Every time you change this value you MUST recreate the LayoutManager instance and to assign it again to the RecyclerView! If you have multiple LayoutManagers consider to restore the value to the default (100ms per inch) just after the creation of the modified LayoutManager, otherwise those LayoutManagers are affected by the new value too.