Google is committed to advancing racial equity for Black communities. See how.

LinearSmoothScroller

open class LinearSmoothScroller : RecyclerView.SmoothScroller
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.SmoothScroller
   ↳ androidx.recyclerview.widget.LinearSmoothScroller

RecyclerView.SmoothScroller implementation which uses a LinearInterpolator until the target position becomes a child of the RecyclerView and then uses a DecelerateInterpolator to slowly approach to target position.

If the RecyclerView.LayoutManager you are using does not implement the RecyclerView.SmoothScroller.ScrollVectorProvider interface, then you must override the computeScrollVectorForPosition(int) method. All the LayoutManagers bundled with the support library implement this interface.

Summary

Constants
static Int

Decides if the child should be snapped from start or end, depending on where it currently is in relation to its parent.

static Int

Align child view's right or bottom with parent view's right or bottom

static Int

Align child view's left or top with parent view's left or top

Public constructors
<init>(context: Context!)

Public methods
open Int
calculateDtToFit(viewStart: Int, viewEnd: Int, boxStart: Int, boxEnd: Int, snapPreference: Int)

Helper method for calculateDxToMakeVisible(android.view.View, int) and calculateDyToMakeVisible(android.view.View, int)

open Int
calculateDxToMakeVisible(view: View!, snapPreference: Int)

Calculates the horizontal scroll amount necessary to make the given view fully visible inside the RecyclerView.

open Int
calculateDyToMakeVisible(view: View!, snapPreference: Int)

Calculates the vertical scroll amount necessary to make the given view fully visible inside the RecyclerView.

Protected methods
open Float

Calculates the scroll speed.

open Int

Calculates the time for deceleration so that transition from LinearInterpolator to DecelerateInterpolator looks smooth.

open Int

Calculates the time it should take to scroll the given distance (in pixels)

open Int

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.

open Int

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.

open Unit

RecyclerView will call this method each time it scrolls until it can find the target position in the layout.

open Unit

Called when smooth scroll is started.

open Unit

Called when smooth scroller is stopped.

open Unit

Called when the target position is laid out.

open Unit

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.

Inherited functions
Properties
DecelerateInterpolator!

Int

Int

LinearInterpolator!

PointF!

Constants

SNAP_TO_ANY

static val SNAP_TO_ANY: Int

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

Value: 0

SNAP_TO_END

static val SNAP_TO_END: Int

Align child view's right or bottom with parent view's right or bottom

Value: 1

SNAP_TO_START

static val SNAP_TO_START: Int

Align child view's left or top with parent view's left or top

Value: -1

Public constructors

<init>

LinearSmoothScroller(context: Context!)

Public methods

calculateDtToFit

open fun calculateDtToFit(
    viewStart: Int,
    viewEnd: Int,
    boxStart: Int,
    boxEnd: Int,
    snapPreference: Int
): Int

Helper method for calculateDxToMakeVisible(android.view.View, int) and calculateDyToMakeVisible(android.view.View, int)

calculateDxToMakeVisible

open fun calculateDxToMakeVisible(
    view: View!,
    snapPreference: