-
public class LinearSmoothScroller extends RecyclerView.SmoothScroller
RecyclerView.SmoothScroller implementation which uses a LinearInterpolator until the target position becomes a child of the RecyclerView and then uses a DecelerateInterpolator to slowly approach to target position.
If the RecyclerView.LayoutManager you are using does not implement the ScrollVectorProvider interface, then you must override the computeScrollVectorForPosition method. All the LayoutManagers bundled with the support library implement this interface.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
SNAP_TO_START
public final static int
SNAP_TO_END
public final static int
SNAP_TO_ANY
-
Constructor Summary
Constructors Constructor Description LinearSmoothScroller(Context context)
-
Method Summary
Modifier and Type Method Description int
calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference)
Helper method for calculateDxToMakeVisible and calculateDyToMakeVisible int
calculateDyToMakeVisible(View view, int snapPreference)
Calculates the vertical scroll amount necessary to make the given view fully visibleinside the RecyclerView. int
calculateDxToMakeVisible(View view, int snapPreference)
Calculates the horizontal scroll amount necessary to make the given view fully visibleinside the RecyclerView. -
Methods inherited from class tds.androidx.recyclerview.widget.RecyclerView.SmoothScroller
computeScrollVectorForPosition, findViewByPosition, getChildCount, getChildPosition, getLayoutManager, getTargetPosition, instantScrollToPosition, isPendingInitialRun, isRunning, setTargetPosition
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
LinearSmoothScroller
LinearSmoothScroller(Context context)
-
-
Method Detail
-
calculateDtToFit
int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference)
Helper method for calculateDxToMakeVisible and calculateDyToMakeVisible
-
calculateDyToMakeVisible
int calculateDyToMakeVisible(View view, int snapPreference)
Calculates the vertical scroll amount necessary to make the given view fully visibleinside the RecyclerView.
- Parameters:
view
- The view which we want to make fully visiblesnapPreference
- The edge which the view should snap to when entering the visiblearea.
-
calculateDxToMakeVisible
int calculateDxToMakeVisible(View view, int snapPreference)
Calculates the horizontal scroll amount necessary to make the given view fully visibleinside the RecyclerView.
- Parameters:
view
- The view which we want to make fully visiblesnapPreference
- The edge which the view should snap to when entering the visiblearea.
-
-
-
-