added in version 22.1.0
belongs to Maven artifact


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 RecyclerView.SmoothScroller.ScrollVectorProvider interface, then you must override the computeScrollVectorForPosition(int) method. All the LayoutManagers bundled with the support library implement this interface.




Decides if the child should be snapped from start or end, depending on where it currently is in relation to its parent.


Align child view's right or bottom with parent view's right or bottom


Align child view's left or top with parent view's left or top


protected final DecelerateInterpolator mDecelerateInterpolator

protected int mInterimTargetDx

protected int mInterimTargetDy

protected final LinearInterpolator mLinearInterpolator

protected PointF mTargetVector

Public constructors

LinearSmoothScroller(Context context)

Public methods

int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference)

Helper method for calculateDxToMakeVisible(android.view.View, int) and calculateDyToMakeVisible(android.view.View, int)

int calculateDxToMakeVisible(View view, int snapPreference)

Calculates the horizontal scroll amount necessary to make the given view fully visible inside the RecyclerView.

int calculateDyToMakeVisible(View view, int snapPreference)

Calculates the vertical scroll amount necessary to make the given view fully visible inside the RecyclerView.

Protected methods

float calculateSpeedPerPixel(DisplayMetrics displayMetrics)

Calculates the scroll speed.

int calculateTimeForDeceleration(int dx)

Calculates the time for deceleration so that transition from LinearInterpolator to DecelerateInterpolator looks smooth.

int calculateTimeForScrolling(int dx)

Calculates the time it should take to scroll the given distance (in pixels)