void prepareForDrop (View view,
View target,
int x,
int y)
Called by the 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: 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: The target view which is being dropped on.
x
int: The left offset of the View that is being dragged. This value
includes the movement caused by the user.
y
int: The top offset of the View that is being dragged. This value
includes the movement caused by the user.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ItemTouchHelper.ViewDropHandler\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1 \nSummary: [Methods](#pubmethods) \\| [\\[Expand All\\]](#) \n\nItemTouchHelper.ViewDropHandler\n===============================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\nstatic\n\n\ninterface\nItemTouchHelper.ViewDropHandler\n`\n\n\n`\n\n\n`\n\n|------------------------------------------------------------------|\n| android.support.v7.widget.helper.ItemTouchHelper.ViewDropHandler |\n\n|---|---|\n| Known Indirect Subclasses [GridLayoutManager](/reference/android/support/v7/widget/GridLayoutManager),[LinearLayoutManager](/reference/android/support/v7/widget/LinearLayoutManager),[WearableLinearLayoutManager](/reference/android/support/wear/widget/WearableLinearLayoutManager) |---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [GridLayoutManager](/reference/android/support/v7/widget/GridLayoutManager) | A [RecyclerView.LayoutManager](/reference/android/support/v7/widget/RecyclerView.LayoutManager) implementations that lays out items in a grid. | | [LinearLayoutManager](/reference/android/support/v7/widget/LinearLayoutManager) | A [RecyclerView.LayoutManager](/reference/android/support/v7/widget/RecyclerView.LayoutManager) implementation which provides similar functionality to [ListView](https://developer.android.com/reference/android/widget/ListView.html). | | [WearableLinearLayoutManager](/reference/android/support/wear/widget/WearableLinearLayoutManager) | This wear-specific implementation of [LinearLayoutManager](/reference/android/support/v7/widget/LinearLayoutManager) provides basic offsetting logic for updating child layout. | ||\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn interface which can be implemented by LayoutManager for better integration with\n[ItemTouchHelper](/reference/android/support/v7/widget/helper/ItemTouchHelper).\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[prepareForDrop](/reference/android/support/v7/widget/helper/ItemTouchHelper.ViewDropHandler#prepareForDrop(android.view.View, android.view.View, int, int))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, `[View](https://developer.android.com/reference/android/view/View.html)` target, int x, int y) ` Called by the [ItemTouchHelper](/reference/android/support/v7/widget/helper/ItemTouchHelper) after a View is dropped over another View. |\n\nPublic methods\n--------------\n\n### prepareForDrop\n\nadded in [version 24.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid prepareForDrop (View view, \n View target, \n int x, \n int y)\n```\n\nCalled by the [ItemTouchHelper](/reference/android/support/v7/widget/helper/ItemTouchHelper) after a View is dropped over another View.\n\n\nA LayoutManager should implement this interface to get ready for the upcoming move\noperation.\n\n\nFor example, LinearLayoutManager sets up a \"scrollToPositionWithOffset\" calls so that\nthe View under drag will be used as an anchor View while calculating the next layout,\nmaking layout stay consistent.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `view` | `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. \u003cbr /\u003e |\n| `target` | `View`: The target view which is being dropped on. \u003cbr /\u003e |\n| `x` | `int`: The `left` offset of the View that is being dragged. This value includes the movement caused by the user. \u003cbr /\u003e |\n| `y` | `int`: The `top` offset of the View that is being dragged. This value includes the movement caused by the user. \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [ItemTouchHelper.ViewDropHandler](/reference/android/support/v7/widget/helper/ItemTouchHelper.ViewDropHandler)\n - [ItemTouchUIUtil](/reference/android/support/v7/widget/helper/ItemTouchUIUtil)\n-\n\n Classes\n -------\n\n - [ItemTouchHelper](/reference/android/support/v7/widget/helper/ItemTouchHelper)\n - [ItemTouchHelper.Callback](/reference/android/support/v7/widget/helper/ItemTouchHelper.Callback)\n - [ItemTouchHelper.SimpleCallback](/reference/android/support/v7/widget/helper/ItemTouchHelper.SimpleCallback)"]]