public static class RecyclerView.SmoothScroller.Action extends Object
RecyclerView.SmoothScroller
.Modifier and Type | Field and Description |
---|---|
static int |
UNDEFINED_DURATION |
Constructor and Description |
---|
Action(int dx,
int dy) |
Action(int dx,
int dy,
int duration) |
Action(int dx,
int dy,
int duration,
Interpolator interpolator) |
Modifier and Type | Method and Description |
---|---|
int |
getDuration() |
int |
getDx() |
int |
getDy() |
Interpolator |
getInterpolator() |
void |
jumpTo(int targetPosition)
Instead of specifying pixels to scroll, use the target position to jump using
RecyclerView.scrollToPosition(int) . |
void |
setDuration(int duration) |
void |
setDx(int dx) |
void |
setDy(int dy) |
void |
setInterpolator(Interpolator interpolator)
Sets the interpolator to calculate scroll steps
|
void |
update(int dx,
int dy,
int duration,
Interpolator interpolator)
Updates the action with given parameters.
|
public static final int UNDEFINED_DURATION
public Action(int dx, int dy)
dx
- Pixels to scroll horizontallydy
- Pixels to scroll verticallypublic Action(int dx, int dy, int duration)
dx
- Pixels to scroll horizontallydy
- Pixels to scroll verticallyduration
- Duration of the animation in millisecondspublic Action(int dx, int dy, int duration, Interpolator interpolator)
dx
- Pixels to scroll horizontallydy
- Pixels to scroll verticallyduration
- Duration of the animation in millisecondsinterpolator
- Interpolator to be used when calculating scroll position in each
animation steppublic void jumpTo(int targetPosition)
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)
, View.setX(float)
,
View.setY(float)
and #setInterpolator(Interpolator)
. If you call
jumpTo(int)
, the other changes will not be considered for this animation
frame.
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)
interpolator
- The interpolator to use. If you specify an interpolator, you must
also set the duration.setDuration(int)
public void update(int dx, int dy, int duration, Interpolator interpolator)
dx
- Pixels to scroll horizontallydy
- Pixels to scroll verticallyduration
- Duration of the animation in millisecondsinterpolator
- Interpolator to be used when calculating scroll position in each
animation step