# 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)

*** ** * ** ***


```
public abstract class RecyclerView.OnFlingListener
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/SnapHelper` | Class intended to support snapping for a `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView`. |

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

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/LinearSnapHelper` | Implementation of the `https://developer.android.com/reference/androidx/recyclerview/widget/SnapHelper` supporting snapping in either vertical or horizontal orientation. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/PagerSnapHelper` | Implementation of the `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnFlingListener` can be used to implement custom fling behavior.

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

## Summary

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

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnFlingListener#onFling(int,int)(int velocityX, int velocityY)` Override this to handle a fling given the velocities in both x and y directions. |

## Public constructors

### OnFlingListener

Added in 1.0.0

```
public OnFlingListener()
```

## Public methods

### onFling

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

```
public abstract boolean onFling(int velocityX, int velocityY)
```

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 `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager` supports scrolling and the fling is not handled by nested scrolls first.

| Parameters |
|---|---|
| `int velocityX` | the fling velocity on the X axis |
| `int velocityY` | the fling velocity on the Y axis |

| Returns |
|---|---|
| `boolean` | true if the fling was handled, false otherwise. |