StickyHeaderSnapHelper
A LinearSnapHelper, which should be used with ListGroupItemsCollection to supports sticky headers in vertical orientation. To have the sticky header in the RecyclerView, StickyHeaderDecoration needs be added to it. In the normal situation, the implementation will snap the RecyclerView to the top. It will find the target view and its top will be snapped to the bottom of the header. However, if the last item in the RecyclerView is visible and it is more close to the bottom than to the top, the RecyclerView will be snapped to the bottom instead of to the top.
Parameters
The adapter is used to snap headers correctly.
The maximum fling velocity. Set it to limit the scroll range. If not set, RecyclerView.getMaxFlingVelocity is used.
An optionally provided method to create a Scroller that is used in calculateScrollDistance.
Constructors
Functions
This method is called when the SnapHelper has intercepted a fling and it needs to know the exact distance required to scroll by in order to snap to the target view.
Calculates the estimated scroll distance in each direction given velocities on both axes. This method is overridden to constrain velocityY to the value of maxFlingVelocityPx.
This method is called when the SnapHelper is ready to start snapping and requires a target view to snap to. It will be explicitly called when the scroll state becomes idle after scrolling. It will also be called when the SnapHelper is preparing to snap after a fling and requires a reference view from the current set of child views. If this method returns null
, SnapHelper will not snap to any view. This method is overridden to find the closest view to the top or sticky header.