SmoothScroller
abstract class SmoothScroller
kotlin.Any | |
↳ | androidx.recyclerview.widget.RecyclerView.SmoothScroller |
Base class for smooth scrolling. Handles basic tracking of the target view position and provides methods to trigger a programmatic scroll.
An instance of SmoothScroller is only intended to be used once. You should create a new instance for each call to LayoutManager#startSmoothScroll(SmoothScroller)
.
Summary
Nested classes | |
---|---|
open |
Holds information about a smooth scroll request by a |
abstract |
An interface which is optionally implemented by custom |
Public constructors | |
---|---|
<init>() |
Public methods | |
---|---|
open PointF? |
computeScrollVectorForPosition(targetPosition: Int) Compute the scroll vector for a given target position. |
open View! |
findViewByPosition(position: Int) |
open Int | |
open Int |
getChildPosition(view: View!) |
open RecyclerView.LayoutManager? | |
open Int |
Returns the adapter position of the target item |
open Unit |
instantScrollToPosition(position: Int) |
open Boolean |
Returns true if SmoothScroller has been started but has not received the first animation callback yet. |
open Boolean | |
open Unit |
setTargetPosition(targetPosition: Int) |
Protected methods | |
---|---|
open Unit |
Normalizes the vector. |
open Unit |
onChildAttachedToWindow(child: View!) |
abstract Unit |
onSeekTargetStep(@Px dx: Int, @Px dy: Int, @NonNull state: RecyclerView.State, @NonNull action: RecyclerView.SmoothScroller.Action) RecyclerView will call this method each time it scrolls until it can find the target position in the layout. |
abstract Unit |
onStart() Called when smooth scroll is started. |
abstract Unit |
onStop() Called when smooth scroller is stopped. |
abstract Unit |
onTargetFound(@NonNull targetView: View, @NonNull state: RecyclerView.State, @NonNull action: RecyclerView.SmoothScroller.Action) Called when the target position is laid out. |
Unit |
stop() Stops running the SmoothScroller in each animation callback. |
Public constructors
<init>
SmoothScroller()
Public methods
computeScrollVectorForPosition
@Nullable open fun computeScrollVectorForPosition(targetPosition: Int): PointF?
Compute the scroll vector for a given target position.
This method can return null if the layout manager cannot calculate a scroll vector for the given position (e.g. it has no current scroll position).
Parameters | |
---|---|
targetPosition |
Int: the position to which the scroller is scrolling |
Return | |
---|---|
PointF? |
the scroll vector for a given target position |
getChildPosition
open fun getChildPosition(view: View!):