RecyclerView.SmoothScroller.Action


public class RecyclerView.SmoothScroller.Action


Holds information about a smooth scroll request by a SmoothScroller.

Summary

Constants

static final int
UNDEFINED_DURATION = -2147483648

Public constructors

Action(@Px int dx, @Px int dy)
Action(@Px int dx, @Px int dy, int duration)
Action(
    @Px int dx,
    @Px int dy,
    int duration,
    @Nullable Interpolator interpolator
)

Public methods

int
@Px int
@Px int
@Nullable Interpolator
void
jumpTo(int targetPosition)

Instead of specifying pixels to scroll, use the target position to jump using scrollToPosition.

void
setDuration(int duration)
void
setDx(@Px int dx)
void
setDy(@Px int dy)
void

Sets the interpolator to calculate scroll steps

void
update(
    @Px int dx,
    @Px int dy,
    int duration,
    @Nullable Interpolator interpolator
)

Updates the action with given parameters.

Constants

UNDEFINED_DURATION

Added in 1.0.0
public static final int UNDEFINED_DURATION = -2147483648

Public constructors

Action

Added in 1.0.0
public Action(@Px int dx, @Px int dy)
Parameters
@Px int dx

Pixels to scroll horizontally

@Px int dy

Pixels to scroll vertically

Action

Added in 1.0.0
public Action(@Px int dx, @Px int dy, int duration)
Parameters
@Px int dx

Pixels to scroll horizontally

@Px int dy

Pixels to scroll vertically

int duration

Duration of the animation in milliseconds

Action

Added in 1.0.0
public Action(
    @Px int dx,
    @Px int dy,
    int duration,
    @Nullable Interpolator interpolator
)
Parameters
@Px int dx

Pixels to scroll horizontally

@Px int dy

Pixels to scroll vertically

int duration

Duration of the animation in milliseconds

@Nullable Interpolator interpolator

Interpolator to be used when calculating scroll position in each animation step

Public methods

getDuration

Added in 1.0.0
public int getDuration()

getDx

Added in 1.0.0
public @Px int getDx()

getDy

Added in 1.0.0
public @Px int getDy()

getInterpolator

Added in 1.0.0
public @Nullable Interpolator getInterpolator()

jumpTo

Added in 1.0.0
public void jumpTo(int targetPosition)

Instead of specifying pixels to scroll, use the target position to jump using scrollToPosition.

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 update, setX, setY and #setInterpolator. If you call jumpTo, the other changes will not be considered for this animation frame.

Parameters
int targetPosition

The target item position to scroll to using instant scrolling.

setDuration

Added in 1.0.0
public void setDuration(int duration)

setDx

Added in 1.0.0
public void setDx(@Px int dx)

setDy

Added in 1.0.0
public void setDy(@Px int dy)

setInterpolator

Added in 1.0.0
public void setInterpolator(@Nullable Interpolator interpolator)

Sets the interpolator to calculate scroll steps

Parameters
@Nullable Interpolator interpolator

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

See also
setDuration

update

Added in 1.0.0
public void update(
    @Px int dx,
    @Px int dy,
    int duration,
    @Nullable Interpolator interpolator
)

Updates the action with given parameters.

Parameters
@Px int dx

Pixels to scroll horizontally

@Px int dy

Pixels to scroll vertically

int duration

Duration of the animation in milliseconds

@Nullable Interpolator interpolator

Interpolator to be used when calculating scroll position in each animation step