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, duration: Int, @Nullable interpolator: Interpolator?) |
Public methods | |
---|---|
open Int | |
open Int |
getDx() |
open Int |
getDy() |
open Interpolator? | |
open Unit |
Instead of specifying pixels to scroll, use the target position to jump using |
open Unit |
setDuration(duration: Int) |
open Unit | |
open Unit | |
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
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 |
Interpolator?: 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. |
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. |
See Also
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 |
Interpolator?: Interpolator to be used when calculating scroll position in each animation step |