# RecyclerView.OnItemTouchListener

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.OnItemTouchListener) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)

*** ** * ** ***


```
public interface RecyclerView.OnItemTouchListener
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.SimpleOnItemTouchListener` | An implementation of `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener` that has empty method bodies and default return values. |

*** ** * ** ***

An OnItemTouchListener allows the application to intercept touch events in progress at the view hierarchy level of the RecyclerView before those touch events are considered for RecyclerView's own scrolling behavior.

This can be useful for applications that wish to implement various forms of gestural manipulation of item views within the RecyclerView. OnItemTouchListeners may intercept a touch interaction already in progress even if the RecyclerView is already handling that gesture stream itself for the purposes of scrolling.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.SimpleOnItemTouchListener` |   |

## Summary

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener#onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView,android.view.MotionEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView rv, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MotionEvent.html e)` Silently observe and/or take over touch events sent to the RecyclerView before they are handled by either the RecyclerView itself or its child views. |
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener#onRequestDisallowInterceptTouchEvent(boolean)(boolean disallowIntercept)` Called when a child of RecyclerView does not want RecyclerView and its ancestors to intercept touch events with `https://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent)`. |
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener#onTouchEvent(androidx.recyclerview.widget.RecyclerView,android.view.MotionEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView rv, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MotionEvent.html e)` Process a touch event as part of a gesture that was claimed by returning true from a previous call to `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener#onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView,android.view.MotionEvent)`. |

## Public methods

### onInterceptTouchEvent

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

```
abstract boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e)
```

Silently observe and/or take over touch events sent to the RecyclerView before they are handled by either the RecyclerView itself or its child views.

The onInterceptTouchEvent methods of each attached OnItemTouchListener will be run in the order in which each listener was added, before any other touch processing by the RecyclerView itself or child views occurs.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView rv` | The RecyclerView whose scroll state has changed. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MotionEvent.html e` | MotionEvent describing the touch event. All coordinates are in the RecyclerView's coordinate system. |

| Returns |
|---|---|
| `boolean` | true if this OnItemTouchListener wishes to begin intercepting touch events, false to continue with the current behavior and continue observing future events in the gesture. |

### onRequestDisallowInterceptTouchEvent

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

```
abstract void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept)
```

Called when a child of RecyclerView does not want RecyclerView and its ancestors to intercept touch events with `https://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent)`.

| Parameters |
|---|---|
| `boolean disallowIntercept` | True if the child does not want the parent to intercept touch events. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewParent.html#requestDisallowInterceptTouchEvent(boolean)` |   |

### onTouchEvent

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

```
abstract void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e)
```

Process a touch event as part of a gesture that was claimed by returning true from a previous call to `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnItemTouchListener#onInterceptTouchEvent(androidx.recyclerview.widget.RecyclerView,android.view.MotionEvent)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView rv` | The RecyclerView whose scroll state has changed. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/MotionEvent.html e` | MotionEvent describing the touch event. All coordinates are in the RecyclerView's coordinate system. |