Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Action

open class Action
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.SmoothScroller.Action

Holds information about a smooth scroll request by a SmoothScroller.

Summary

Constants

static Int

Public constructors

<init>(@Px dx: Int, @Px dy: Int)

<init>(@Px dx: Int, @Px dy: Int, duration: Int)

<init>(@Px dx: Int, @Px dy: Int, duration: Int, @Nullable interpolator: Interpolator?)

Public methods

open Int

open Int

open Int

open Interpolator?

open Unit
jumpTo(targetPosition: Int)

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

open Unit
setDuration(duration: Int)

open Unit
setDx(@Px dx: Int)

open Unit
setDy(@Px dy: Int)

open Unit
setInterpolator(@Nullable interpolator: Interpolator?)

Sets the interpolator to calculate scroll steps

open Unit
update(@Px dx: Int, @Px dy: Int, duration: Int, @Nullable interpolator: Interpolator?)

Updates the action with given parameters.

Constants

UNDEFINED_DURATION

static val UNDEFINED_DURATION: Int
Value: RecyclerView.UNDEFINED_DURATION

Public constructors

<init>

Action(@Px dx: Int, @Px dy: Int)
Parameters
dx Int: Pixels to scroll horizontally
dy Int: Pixels to scroll vertically

<init>

Action(@Px dx: Int, @Px dy: Int, duration: Int)
Parameters
dx Int: Pixels to scroll horizontally
dy Int: Pixels to scroll vertically
duration Int: Duration of the animation in milliseconds

<init>

Action(@Px dx: Int, @Px dy: Int, duration: Int, @Nullable interpolator: Interpolator?)
Parameters
dx Int: Pixels to scroll horizontally
dy Int: Pixels to scroll vertically
duration Int: Duration of the animation in milliseconds
interpolator Int: Interpolator to be used when calculating scroll position in each animation step

Public methods

getDuration

open fun getDuration(): Int

getDx

@Px open fun getDx(): Int

getDy

@Px open fun getDy(): Int

getInterpolator

@Nullable open fun getInterpolator(): Interpolator?

jumpTo

open fun jumpTo(targetPosition: Int): Unit

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

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

setDuration

open fun setDuration(duration: Int): Unit

setDx

open fun setDx(@Px dx: Int): Unit

setDy

open fun setDy(@Px dy: Int): Unit

setInterpolator

open fun setInterpolator(@Nullable interpolator: Interpolator?): Unit

Sets the interpolator to calculate scroll steps

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

update

open fun update(@Px dx: Int, @Px dy: Int, duration: Int, @Nullable interpolator: Interpolator?): Unit

Updates the action with given parameters.

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