How to add Drag/Drop in Android App using android studio

0 782

Android Drag and Drop

This tutorial describes how to add Android Drag and Drop in android Application. The Android Drag/Drop structure allows the user to move data from view to another in the current layout, with the help of graphical drag and drop gesture. To start a drag you need to include both the data you are moving and metadata defining this data as part of the call to the system. The drag and drop gesture is used in multiple Android Applications, mostly in Android Games.

Let me give you a simple example of how to implement drag and drop framework in Android.

Steps to Follow

Before following these steps you must have installed JDK 7.0 or above and Android 2.0 on your device or PC.

  1. Firstly create a New Project in Android Studio and name it as DragandDrop.
  2. The minimum API level should be set to 16 so that it can run most of the Android device in Google Play.
  3. Choose Blank Activity and name it press finish.
  4. Configure two Linearlayout with a button to drag and drop, inside activity_main.xml as shown below.

5. Write the following code inside MainActivity.java.

Download Source code

Comments

comments

Leave A Reply

Your email address will not be published.