# RecyclerView.OnFlingListener

# RecyclerView.OnFlingListener

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.OnFlingListener)  
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.OnFlingListener "View this page in Java")

<br />

```
abstract class RecyclerView.OnFlingListener
```

<br />

Known direct subclasses  
[SnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SnapHelper)  

|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [SnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SnapHelper) | Class intended to support snapping for a[RecyclerView](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView). |

Known indirect subclasses  
[LinearSnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearSnapHelper),[PagerSnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/PagerSnapHelper)  

|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LinearSnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearSnapHelper) | Implementation of the[SnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SnapHelper)supporting snapping in either vertical or horizontal orientation.             |
| [PagerSnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/PagerSnapHelper)   | Implementation of the[SnapHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SnapHelper)supporting pager style snapping in either vertical or horizontal orientation. |

*** ** * ** ***

This class defines the behavior of fling if the developer wishes to handle it.

Subclasses of[OnFlingListener](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnFlingListener)can be used to implement custom fling behavior.  

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

## Summary

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

|                                      ### Public functions                                      |
|------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [onFling](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnFlingListener#onFling(int,int))`(velocityX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, velocityY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Override this to handle a fling given the velocities in both x and y directions. |

## Public constructors

### OnFlingListener

Added in 1.0.0  

```
OnFlingListener()
```  

## Public functions

### onFling

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

```
abstract fun onFling(velocityX: Int, velocityY: Int): Boolean
```

Override this to handle a fling given the velocities in both x and y directions. Note that this method will only be called if the associated[LayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.LayoutManager)supports scrolling and the fling is not handled by nested scrolls first.  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|----------------------------------|
| `velocityX: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the fling velocity on the X axis |
| `velocityY: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the fling velocity on the Y axis |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if the fling was handled, false otherwise. |