belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1
RecyclerView.SmoothScroller
  public
  static
  
  abstract
  class
  RecyclerView.SmoothScroller
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.v7.widget.RecyclerView.SmoothScroller | 
|  Known Direct Subclasses | 
Base class for smooth scrolling. Handles basic tracking of the target view position and provides methods to trigger a programmatic scroll.
See also:
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | RecyclerView.SmoothScroller.ActionHolds information about a smooth scroll request by a  | 
| 
        
        
        
        
        interface | RecyclerView.SmoothScroller.ScrollVectorProviderAn interface which is optionally implemented by custom  | 
| Public constructors | |
|---|---|
| 
      RecyclerView.SmoothScroller()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        PointF | 
      computeScrollVectorForPosition(int targetPosition)
      Compute the scroll vector for a given target position. | 
| 
        
        
        
        
        
        View | 
      findViewByPosition(int position)
       | 
| 
        
        
        
        
        
        int | 
      getChildCount()
       | 
| 
        
        
        
        
        
        int | 
      getChildPosition(View view)
       | 
| 
        
        
        
        
        
        RecyclerView.LayoutManager | 
      getLayoutManager()
       | 
| 
        
        
        
        
        
        int | 
      getTargetPosition()
      Returns the adapter position of the target item | 
| 
        
        
        
        
        
        void | 
      instantScrollToPosition(int position)
      
      This method was deprecated
      in API level 24.1.0.
    Use  | 
| 
        
        
        
        
        
        boolean | 
      isPendingInitialRun()
      Returns true if SmoothScroller has been started but has not received the first animation callback yet. | 
| 
        
        
        
        
        
        boolean | 
      isRunning()
       | 
| 
        
        
        
        
        
        void | 
      setTargetPosition(int targetPosition)
       | 
| Protected methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      normalize(PointF scrollVector)
      Normalizes the vector. | 
| 
        
        
        
        
        
        void | 
      onChildAttachedToWindow(View child)
       | 
| 
        abstract
        
        
        
        
        void | 
      onSeekTargetStep(int dx, int dy, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)
      RecyclerView will call this method each time it scrolls until it can find the target position in the layout. | 
| 
        abstract
        
        
        
        
        void | 
      onStart()
      Called when smooth scroll is started. | 
| 
        abstract
        
        
        
        
        void | 
      onStop()
      Called when smooth scroller is stopped. | 
| 
        abstract
        
        
        
        
        void | 
      onTargetFound(View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)
      Called when the target position is laid out. | 
| 
        
        
        
        final
        
        void | 
      stop()
      Stops running the SmoothScroller in each animation callback. | 
| Inherited methods | |
|---|---|
|  From
class 
  
    java.lang.Object
  
 | |
Public constructors
Public methods
computeScrollVectorForPosition
PointF computeScrollVectorForPosition (int targetPosition)
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 | 
| Returns | |
|---|---|
| PointF | the scroll vector for a given target position | 
findViewByPosition
View findViewByPosition (int position)
| Parameters | |
|---|---|
| position | int | 
| Returns | |
|---|---|
| View | |
See also:
getChildPosition
int getChildPosition (View view)
| Parameters | |
|---|---|
| view | View | 
| Returns | |
|---|---|
| int | |
getLayoutManager
RecyclerView.LayoutManager getLayoutManager ()
| Returns | |
|---|---|
| RecyclerView.LayoutManager | The LayoutManager to which this SmoothScroller is attached. Will return nullafter the SmoothScroller is stopped. | 
getTargetPosition
int getTargetPosition ()
Returns the adapter position of the target item
| Returns | |
|---|---|
| int | Adapter position of the target item or NO_POSITIONif no target view is set. | 
instantScrollToPosition
void instantScrollToPosition (int position)
      This method was deprecated
      in API level 24.1.0.
    Use jumpTo(int).
  
| Parameters | |
|---|---|
| position | int | 
See also:
isPendingInitialRun
boolean isPendingInitialRun ()
Returns true if SmoothScroller has been started but has not received the first animation callback yet.
| Returns | |
|---|---|
| boolean | True if this SmoothScroller is waiting to start | 
isRunning
boolean isRunning ()
| Returns | |
|---|---|
| boolean | True if SmoothScroller is currently active | 
setTargetPosition
void setTargetPosition (int targetPosition)
| Parameters | |
|---|---|
| targetPosition | int | 
Protected methods
normalize
void normalize (PointF scrollVector)
Normalizes the vector.
| Parameters | |
|---|---|
| scrollVector | PointF: The vector that points to the target scroll position | 
onChildAttachedToWindow
void onChildAttachedToWindow (View child)
| Parameters | |
|---|---|
| child | View | 
onSeekTargetStep
void onSeekTargetStep (int dx, 
                int dy, 
                RecyclerView.State state, 
                RecyclerView.SmoothScroller.Action action)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.
| Parameters | |
|---|---|
| dx | int: Last scroll amount horizontally | 
| dy | int: Last scroll amount vertically | 
| state | RecyclerView.State: Transient state of RecyclerView | 
| action | RecyclerView.SmoothScroller.Action: If you want to trigger a new smooth scroll and cancel the previous one,
                  update this object. | 
onStart
void onStart ()
Called when smooth scroll is started. This might be a good time to do setup.
onStop
void onStop ()
Called when smooth scroller is stopped. This is a good place to cleanup your state etc.
See also:
onTargetFound
void onTargetFound (View targetView, RecyclerView.State state, RecyclerView.SmoothScroller.Action action)
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.
| Parameters | |
|---|---|
| targetView | View: The view element which render the target position. | 
| state | RecyclerView.State: Transient state of RecyclerView | 
| action | RecyclerView.SmoothScroller.Action: Action instance that you should update to define final scroll action
                      towards the targetView | 
stop
void stop ()
Stops running the SmoothScroller in each animation callback. Note that this does not
 cancel any existing RecyclerView.SmoothScroller.Action updated by
 onTargetFound(android.view.View, RecyclerView.State, SmoothScroller.Action) or
 onSeekTargetStep(int, int, RecyclerView.State, SmoothScroller.Action).
- Annotations
- Interfaces- ActionMenuView.OnMenuItemClickListener
- PopupMenu.OnDismissListener
- PopupMenu.OnMenuItemClickListener
- RecyclerView.ChildDrawingOrderCallback
- RecyclerView.ItemAnimator.ItemAnimatorFinishedListener
- RecyclerView.LayoutManager.LayoutPrefetchRegistry
- RecyclerView.OnChildAttachStateChangeListener
- RecyclerView.OnItemTouchListener
- RecyclerView.RecyclerListener
- RecyclerView.SmoothScroller.ScrollVectorProvider
- SearchView.OnCloseListener
- SearchView.OnQueryTextListener
- SearchView.OnSuggestionListener
- ShareActionProvider.OnShareTargetSelectedListener
- ThemedSpinnerAdapter
- Toolbar.OnMenuItemClickListener
 
- Classes- ActionMenuView
- ActionMenuView.LayoutParams
- AppCompatAutoCompleteTextView
- AppCompatButton
- AppCompatCheckBox
- AppCompatCheckedTextView
- AppCompatEditText
- AppCompatImageButton
- AppCompatImageView
- AppCompatMultiAutoCompleteTextView
- AppCompatRadioButton
- AppCompatRatingBar
- AppCompatSeekBar
- AppCompatSpinner
- AppCompatTextView
- CardView
- DefaultItemAnimator
- DividerItemDecoration
- GridLayout
- GridLayout.Alignment
- GridLayout.LayoutParams
- GridLayout.Spec
- GridLayoutManager
- GridLayoutManager.DefaultSpanSizeLookup
- GridLayoutManager.LayoutParams
- GridLayoutManager.SpanSizeLookup
- LinearLayoutCompat
- LinearLayoutCompat.LayoutParams
- LinearLayoutManager
- LinearLayoutManager.LayoutChunkResult
- LinearSmoothScroller
- LinearSnapHelper
- ListPopupWindow
- OrientationHelper
- PagerSnapHelper
- PopupMenu
- RecyclerView
- RecyclerView.Adapter
- RecyclerView.AdapterDataObserver
- RecyclerView.EdgeEffectFactory
- RecyclerView.ItemAnimator
- RecyclerView.ItemAnimator.ItemHolderInfo
- RecyclerView.ItemDecoration
- RecyclerView.LayoutManager
- RecyclerView.LayoutManager.Properties
- RecyclerView.LayoutParams
- RecyclerView.OnFlingListener
- RecyclerView.OnScrollListener
- RecyclerView.RecycledViewPool
- RecyclerView.Recycler
- RecyclerView.SimpleOnItemTouchListener
- RecyclerView.SmoothScroller
- RecyclerView.SmoothScroller.Action
- RecyclerView.State
- RecyclerView.ViewCacheExtension
- RecyclerView.ViewHolder
- RecyclerViewAccessibilityDelegate
- RecyclerViewAccessibilityDelegate.ItemDelegate
- SearchView
- ShareActionProvider
- SimpleItemAnimator
- SnapHelper
- StaggeredGridLayoutManager
- StaggeredGridLayoutManager.LayoutParams
- SwitchCompat
- ThemedSpinnerAdapter.Helper
- Toolbar
- Toolbar.LayoutParams
- Toolbar.SavedState
- TooltipCompat
 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
