public class

RecyclerView.SmoothScroller.Action

extends java.lang.Object

 java.lang.Object

↳androidx.recyclerview.widget.RecyclerView.SmoothScroller.Action

Overview

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

Summary

Fields
public static final intUNDEFINED_DURATION

Constructors
publicAction(int dx, int dy)

publicAction(int dx, int dy, int duration)

publicAction(int dx, int dy, int duration, Interpolator interpolator)

Methods
public intgetDuration()

public intgetDx()

public intgetDy()

public InterpolatorgetInterpolator()

public voidjumpTo(int targetPosition)

Instead of specifying pixels to scroll, use the target position to jump using RecyclerView.scrollToPosition(int).

public voidsetDuration(int duration)

public voidsetDx(int dx)

public voidsetDy(int dy)

public voidsetInterpolator(Interpolator interpolator)

Sets the interpolator to calculate scroll steps

public voidupdate(int dx, int dy, int duration, Interpolator interpolator)

Updates the action with given parameters.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int UNDEFINED_DURATION

Constructors

public Action(int dx, int dy)

Parameters:

dx: Pixels to scroll horizontally
dy: Pixels to scroll vertically

public Action(int dx, int dy, int duration)

Parameters:

dx: Pixels to scroll horizontally
dy: Pixels to scroll vertically
duration: Duration of the animation in milliseconds

public Action(int dx, int dy, int duration, Interpolator interpolator)

Parameters:

dx: Pixels to scroll horizontally
dy: Pixels to scroll vertically
duration: Duration of the animation in milliseconds
interpolator: Interpolator to be used when calculating scroll position in each animation step

Methods

public void jumpTo(int targetPosition)

Instead of specifying pixels to scroll, use the target position to jump using RecyclerView.scrollToPosition(int).

You may prefer using this method if scroll target is really far away and you prefer to jump to a location and smooth scroll afterwards.

Note that calling this method takes priority over other update methods such as RecyclerView.SmoothScroller.Action.update(int, int, int, Interpolator), RecyclerView.SmoothScroller.Action, RecyclerView.SmoothScroller.Action and #RecyclerView.SmoothScroller.Action.setInterpolator(Interpolator). If you call RecyclerView.SmoothScroller.Action.jumpTo(int), the other changes will not be considered for this animation frame.

Parameters:

targetPosition: The target item position to scroll to using instant scrolling.

public int getDx()

public void setDx(int dx)

public int getDy()

public void setDy(int dy)

public int getDuration()

public void setDuration(int duration)

public Interpolator getInterpolator()

public void setInterpolator(Interpolator interpolator)

Sets the interpolator to calculate scroll steps

Parameters:

interpolator: The interpolator to use. If you specify an interpolator, you must also set the duration.

See also: RecyclerView.SmoothScroller.Action.setDuration(int)

public void update(int dx, int dy, int duration, Interpolator interpolator)

Updates the action with given parameters.

Parameters:

dx: Pixels to scroll horizontally
dy: Pixels to scroll vertically
duration: Duration of the animation in milliseconds
interpolator: Interpolator to be used when calculating scroll position in each animation step