DragAndDrop

  
Accept drag-and-drop data from another app or within an app, and show a consistent drop target affordance.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
May 11, 2022 1.0.0 - - -

Declaring dependencies

To add a dependency on DragAndDrop, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    implementation "androidx.draganddrop:draganddrop:1.0.0"
}

Kotlin

dependencies {
    implementation("androidx.draganddrop:draganddrop:1.0.0")
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.0

Version 1.0.0

May 11, 2022

androidx.draganddrop:draganddrop:1.0.0 is released. Version 1.0.0 contains these commits.

Major features of 1.0.0

DropHelper, the first member of the draganddrop library, is a utility class that simplifies implementation of drag and drop capabilities. Use DropHelper to specify drop targets, customize drop target highlighting, and define how dropped data is handled.

  • DropHelper leverages Jetpack’s OnReceiveContentListener to provide target-specific processing of drag and drop ClipData. DropHelper enhances the user experience by configuring drop targets to display a highlight as users drag content over the targets. The DropHelper.Options nested class enables you to customize the appearance of the default highlight.
  • DropHelper attaches an OnReceiveContentListener to drop targets and configures drop targets to listen for drag and drop events. Do not attach an OnDragListener or additional OnReceiveContentListener to drop targets when using DropHelper.
  • DropHelper.Options gives you the ability to list all EditText elements contained in the view hierarchy of complex drop targets. If any are present, they must be specified in this way. DropHelper prevents the EditText elements from stealing focus from the drop target when users drag data over the target. If the drag and drop ClipData includes text and URI data, DropHelper selects one of the EditText elements in the drop target to handle the text data when the ClipData is dropped.

For more information, see the Drag and drop developer’s guide.

Version 1.0.0-rc01

April 20, 2022

androidx.draganddrop:draganddrop:1.0.0-rc01 is released. Version 1.0.0-rc01 contains these commits.

  • No changes since the last beta release.

Version 1.0.0-beta01

March 23, 2022

androidx.draganddrop:draganddrop:1.0.0-beta01 is released. Version 1.0.0-beta01 contains these commits.

  • No changes since last alpha release.

Version 1.0.0-alpha04

February 23, 2022

androidx.draganddrop:draganddrop:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.

API Changes

  • DragEvents with a non-null localState will not trigger highlighting by default. There is a configuration option to change this behavior. (I55792)

Version 1.0.0-alpha03

January 26, 2022

androidx.draganddrop:draganddrop:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

New Features

  • On devices running Android S or later, DropHelper now delegates to the system implementation of OnReceiveContentListener, automatically providing support for input methods other than drag and drop.

Version 1.0.0-alpha02

December 15, 2021

androidx.draganddrop:draganddrop:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

Features in initial release

DropHelper, the first member of the draganddrop library, is a utility class that simplifies implementation of drag and drop capabilities. Use DropHelper to specify drop targets, customize drop target highlighting, and define how dropped data is handled.

DropHelper leverages Jetpack’s OnReceiveContentListener to provide target-specific processing of drag and drop ClipData. DropHelper enhances the user experience by configuring drop targets to display a highlight as users drag content over the targets. The DropHelper.Options nested class enables you to customize the color and corner radius of the default highlight.

DropHelper.Options also gives you the ability to list all EditText elements contained in the view hierarchy of complex drop targets. DropHelper prevents the EditText elements from stealing focus from the drop target when users drag data over the target. If the drag and drop ClipData includes text and URI data, DropHelper selects one of the EditText elements in the drop target to handle the text data when the ClipData is dropped.

For more information, see the Drag and drop developer’s guide.