# ItemTouchHelper.ViewDropHandler

# ItemTouchHelper.ViewDropHandler

Artifact:[androidx.recyclerview:recyclerview](https://developer.android.com/jetpack/androidx/releases/recyclerview)  
[View Source](https://cs.android.com/search?q=file:androidx/recyclerview/widget/ItemTouchHelper.java+class:androidx.recyclerview.widget.ItemTouchHelper.ViewDropHandler)  
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/ItemTouchHelper.ViewDropHandler "View this page in Java")

<br />

```
interface ItemTouchHelper.ViewDropHandler
```

<br />

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

|------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [LinearLayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearLayoutManager) | A[RecyclerView.LayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.LayoutManager)implementation which provides similar functionality to[android.widget.ListView](https://developer.android.com/reference/android/widget/ListView.html). |

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

|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [GridLayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/GridLayoutManager)             | A[RecyclerView.LayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.LayoutManager)implementations that lays out items in a grid.                                  |
| [WearableLinearLayoutManager](https://developer.android.com/reference/kotlin/androidx/wear/widget/WearableLinearLayoutManager) | This wear-specific implementation of[LinearLayoutManager](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearLayoutManager)provides basic offsetting logic for updating child layout. |

*** ** * ** ***

An interface which can be implemented by LayoutManager for better integration with[ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper).

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [prepareForDrop](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper.ViewDropHandler#prepareForDrop(android.view.View,android.view.View,int,int))`(view: `[View](https://developer.android.com/reference/android/view/View.html)`, target: `[View](https://developer.android.com/reference/android/view/View.html)`, x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, y: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called by the[ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper)after a View is dropped over another View. |

## Public functions

### prepareForDrop

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

```
fun prepareForDrop(view: View, target: View, x: Int, y: Int): Unit
```

Called by the[ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper)after a View is dropped over another View.

A LayoutManager should implement this interface to get ready for the upcoming move operation.

For example, LinearLayoutManager sets up a "scrollToPositionWithOffset" calls so that the View under drag will be used as an anchor View while calculating the next layout, making layout stay consistent.  

|                                    Parameters                                    |
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `view: `[View](https://developer.android.com/reference/android/view/View.html)   | The View which is being dragged. It is very likely that user is still dragging this View so there might be other calls to`prepareForDrop()`after this one. |
| `target: `[View](https://developer.android.com/reference/android/view/View.html) | The target view which is being dropped on.                                                                                                                 |
| `x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The`left`offset of the View that is being dragged. This value includes the movement caused by the user.                                                    |
| `y: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The`top`offset of the View that is being dragged. This value includes the movement caused by the user.                                                     |