manjusg
manjusg

Reputation: 2263

Using Android Drag and Drop framework in My custom Launcher app

I am trying to develop custom launcher app (with unlimited number of home pages)and i need to implement Drag and Drop as done in Launcher2(android 4.2).

So i found two approaches

1) Drag and Drop framework
2) Use the android launcher2 way like implementation DragController, DragSource as explained here.

But i am struggling to understand why didn't Android guys didn't use the Drag and Drop framework developed by them in their own application. Can anyone brief regarding possible rationale behind their approach?( i mean in terms of memory/performance)

Thanks in advance.

Upvotes: 18

Views: 2692

Answers (5)

manjusg
manjusg

Reputation: 2263

Drag and Drop in Android Launcher is done as Overlay drawing within the same ViewGroup and in same window . But android drag and drop approach creates a separate window with a separate window type altogether .

Resource and memory wise standard android drag and drop approach is costlier.

If performance is very critical my suggestion is go as per Android launcher way else prefer standard android approach its easy and simple.

Upvotes: 2

Jignesh Shah
Jignesh Shah

Reputation: 659

The Android drag and drop framework is very basic as compared to the one used in the Launcher app.

The Launcher app has a myriad of "layers" and the drag and drop occurs accross these layers, namely the DragLayer, Workspace and the All Apps view etc. It uses window flags and dynamically adds/removes views to the DragLayer when a drag is in progress and a multitude of activities monitor the drag. For more details look at the DragLayer.java and Workspace.java files particularly.

Upvotes: 3

Suresh Sharma
Suresh Sharma

Reputation: 1844

You should use WindowManaager to control Drag And Drop if in case your Application is not so much complex. This is easy to implement and work on Position changed. get the code Here

Upvotes: 0

Chandra Sekar
Chandra Sekar

Reputation: 82

http://javapapers.com/android/android-drag-and-drop/. This is the best drag and drop example since i have implemented the same in my application. Note: It will support versions only above 11. The drag and drop feature will not support for version 10. Instead u have to move the fields in a absolute layout by settin X and Y positons. But Absolute layout is completely deprecated...

Upvotes: 0

snapix
snapix

Reputation: 344

Drag and Drop framework is sice api 11. My guess is, lot of code for launcher was written before that, and noone had time to refactor it yet. But api works similar like second approach.

Upvotes: 0

Related Questions