java.lang.Object | ||
↳ | android.support.v7.widget.RecyclerView.SmoothScroller | |
↳ | android.support.v7.widget.LinearSmoothScroller |
RecyclerView.SmoothScroller
implementation which uses
LinearInterpolator
until the target position becames a child of
the RecyclerView and then uses
DecelerateInterpolator
to slowly approach to target position.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | SNAP_TO_ANY |
Decides if the child should be snapped from start or end, depending on where it currently is in relation to its parent. |
|||||||||
int | SNAP_TO_END | Align child view's right or bottom with parent view's right or bottom | |||||||||
int | SNAP_TO_START | Align child view's left or top with parent view's left or top |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
mDecelerateInterpolator | |||||||||||
mInterimTargetDx | |||||||||||
mInterimTargetDy | |||||||||||
mLinearInterpolator | |||||||||||
mTargetVector |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calculates the horizontal scroll amount necessary to make the given view fully visible
inside the RecyclerView.
| |||||||||||
Calculates the vertical scroll amount necessary to make the given view fully visible
inside the RecyclerView.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calculates the scroll speed.
| |||||||||||
Calculates the time for deceleration so that transition from LinearInterpolator to DecelerateInterpolator looks smooth. | |||||||||||
Calculates the time it should take to scroll the given distance (in pixels)
| |||||||||||
When scrolling towards a child view, this method defines whether we should align the left
or the right edge of the child with the parent RecyclerView.
| |||||||||||
When scrolling towards a child view, this method defines whether we should align the top
or the bottom edge of the child with the parent RecyclerView.
| |||||||||||
RecyclerView will call this method each time it scrolls until it can find the target position in the layout. | |||||||||||
Called when smooth scroll is started.
| |||||||||||
Called when smooth scroller is stopped.
| |||||||||||
Called when the target position is laid out.
| |||||||||||
When the target scroll position is not a child of the RecyclerView, this method calculates
a direction vector towards that child and triggers a smooth scroll.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v7.widget.RecyclerView.SmoothScroller
| |||||||||||
From class
java.lang.Object
|
Decides if the child should be snapped from start or end, depending on where it currently is in relation to its parent.
For instance, if the view is virtually on the left of RecyclerView, using
SNAP_TO_ANY
is the same as using SNAP_TO_START
Align child view's right or bottom with parent view's right or bottom
Align child view's left or top with parent view's left or top
Calculates the horizontal scroll amount necessary to make the given view fully visible inside the RecyclerView.
view | The view which we want to make fully visible |
---|---|
snapPreference | The edge which the view should snap to when entering the visible
area. One of SNAP_TO_START , SNAP_TO_END or
SNAP_TO_END |
Calculates the vertical scroll amount necessary to make the given view fully visible inside the RecyclerView.
view | The view which we want to make fully visible |
---|---|
snapPreference | The edge which the view should snap to when entering the visible
area. One of SNAP_TO_START , SNAP_TO_END or
SNAP_TO_END . |
Calculates the scroll speed.
displayMetrics | DisplayMetrics to be used for real dimension calculations |
---|
Calculates the time for deceleration so that transition from LinearInterpolator to DecelerateInterpolator looks smooth.
dx | Distance to scroll |
---|
Calculates the time it should take to scroll the given distance (in pixels)
dx | Distance in pixels that we want to scroll |
---|
When scrolling towards a child view, this method defines whether we should align the left or the right edge of the child with the parent RecyclerView.
When scrolling towards a child view, this method defines whether we should align the top or the bottom edge of the child with the parent RecyclerView.
RecyclerView will call this method each time it scrolls until it can find the target position in the layout.
SmoothScroller should check dx, dy and if scroll should be changed, update the
provided RecyclerView.SmoothScroller.Action
to define the next scroll.
dx | Last scroll amount horizontally |
---|---|
dy | Last scroll amount verticaully |
state | Transient state of RecyclerView |
action | If you want to trigger a new smooth scroll and cancel the previous one, update this object. |
Called when smooth scroll is started. This might be a good time to do setup.
Called when smooth scroller is stopped. This is a good place to cleanup your state etc.
Called when the target position is laid out. This is the last callback SmoothScroller
will receive and it should update the provided RecyclerView.SmoothScroller.Action
to define the scroll
details towards the target view.
targetView | The view element which render the target position. |
---|---|
state | Transient state of RecyclerView |
action | Action instance that you should update to define final scroll action towards the targetView |
When the target scroll position is not a child of the RecyclerView, this method calculates a direction vector towards that child and triggers a smooth scroll.