public static abstract class RecyclerView.SmoothScroller
extends Object

   ↳ androidx.recyclerview.widget.RecyclerView.SmoothScroller

Base class for smooth scrolling. Handles basic tracking of the target view position and provides methods to trigger a programmatic scroll.

An instance of SmoothScroller is only intended to be used once. You should create a new instance for each call to RecyclerView.LayoutManager.startSmoothScroll(SmoothScroller).


Nested classes

class RecyclerView.SmoothScroller.Action

Holds information about a smooth scroll request by a RecyclerView.SmoothScroller

interface RecyclerView.SmoothScroller.ScrollVectorProvider

An interface which is optionally implemented by custom RecyclerView.LayoutManager to provide a hint to a RecyclerView.SmoothScroller about the location of the target position. 

Public constructors


Public methods

PointF computeScrollVectorForPosition(int targetPosition)

Compute the scroll vector for a given target position.

View findViewByPosition(int position)
int getChildCount()
int getChildPosition(View view)
RecyclerView.LayoutManager getLayoutManager()
int getTargetPosition()

Returns the adapter position of the target item

void instantScrollToPosition(int position)

This method is deprecated. Use RecyclerView.SmoothScroller.Action.jumpTo(int).

boolean isPendingInitialRun()

Returns true if SmoothScroller has been started but has not received the first animation callback yet.

boolean isRunning()
void setTargetPosition(int targetPosition)

Protected methods

void normalize(PointF scrollVector)

Normalizes the vector.

void onChildAttachedToWindow(View child)
abstract void onSeekTargetStep(int dx, int dy, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)

RecyclerView will call this method each time it scrolls until it can find the target position in the layout.

abstract void onStart()

Called when smooth scroll is started.

abstract void onStop()

Called when smooth scroller is stopped.

abstract void onTargetFound(View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)

Called when the target position is laid out.

final void stop()

Stops running the SmoothScroller in each animation callback.

Inherited methods

Public constructors


public SmoothScroller ()

Public methods


public PointF computeScrollVectorForPosition (int targetPosition)

Compute the scroll vector for a given target position.

This method can return null if the layout manager cannot calculate a scroll vector for the given position (e.g. it has no current scroll position).

targetPosition int: the position to which the scroller is scrolling

PointF the scroll vector for a given target position