# RecyclerView.OnScrollListener

# RecyclerView.OnScrollListener

Artifact:[androidx.recyclerview:recyclerview](https://developer.android.com/jetpack/androidx/releases/recyclerview)  
[View Source](https://cs.android.com/search?q=file:androidx/recyclerview/widget/RecyclerView.java+class:androidx.recyclerview.widget.RecyclerView.OnScrollListener)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnScrollListener "View this page in Java")

<br />

```
abstract class RecyclerView.OnScrollListener
```

<br />

*** ** * ** ***

An OnScrollListener can be added to a RecyclerView to receive messages when a scrolling event has occurred on that RecyclerView.  

|                                                                                            See also                                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [addOnScrollListener](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#addOnScrollListener(androidx.recyclerview.widget.RecyclerView.OnScrollListener)) |   |
| [clearOnChildAttachStateChangeListeners](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#clearOnChildAttachStateChangeListeners())                     |   |

## Summary

|                                                               ### Public constructors                                                                |
|------------------------------------------------------------------------------------------------------------------------------------------------------|
| [OnScrollListener](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnScrollListener#OnScrollListener())`()` |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onScrollStateChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnScrollListener#onScrollStateChanged(androidx.recyclerview.widget.RecyclerView,int))`(recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`, newState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Callback method to be invoked when RecyclerView's scroll state changes.                                                             |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onScrolled](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnScrollListener#onScrolled(androidx.recyclerview.widget.RecyclerView,int,int))`(recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView)`, dx: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, dy: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Callback method to be invoked when the RecyclerView has been scrolled. |

## Public constructors

### OnScrollListener

Added in 1.0.0  

```
OnScrollListener()
```  

## Public functions

### onScrollStateChanged

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int): Unit
```

Callback method to be invoked when RecyclerView's scroll state changes.  

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView) | The RecyclerView whose scroll state has changed.                                                                                                                                                                                                                                                                                                                                                                                                        |
| `newState: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                  | The updated scroll state. One of[SCROLL_STATE_IDLE](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#SCROLL_STATE_IDLE()),[SCROLL_STATE_DRAGGING](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#SCROLL_STATE_DRAGGING())or[SCROLL_STATE_SETTLING](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#SCROLL_STATE_SETTLING()). |

### onScrolled

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int): Unit
```

Callback method to be invoked when the RecyclerView has been scrolled. This will be called after the scroll has completed.

This callback will also be called if visible item range changes after a layout calculation. In that case, dx and dy will be 0.  

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| `recyclerView: `[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView) | The RecyclerView which scrolled. |
| `dx: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                        | The amount of horizontal scroll. |
| `dy: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                        | The amount of vertical scroll.   |