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

*** ** * ** ***


```
public interface ItemTouchHelper.ViewDropHandler
```

<br />

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

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

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

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

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/ItemTouchHelper.ViewDropHandler#prepareForDrop(android.view.View,android.view.View,int,int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html view, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html target, int x, int y)` Called by the `https://developer.android.com/reference/androidx/recyclerview/widget/ItemTouchHelper` after a View is dropped over another View. |

## Public methods

### prepareForDrop

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

```
abstract void prepareForDrop(@NonNull View view, @NonNull View target, int x, int y)
```

Called by the `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html view` | 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. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html target` | The target view which is being dropped on. |
| `int x` | The `left` offset of the View that is being dragged. This value includes the movement caused by the user. |
| `int y` | The `top` offset of the View that is being dragged. This value includes the movement caused by the user. |