Android Question How to create "Long-press drag" with CustomListview?

fredo

Well-Known Member
Licensed User
Longtime User
The goal is to implement a selection principle that is used in the Google Photo App:

19-04-_2018_09-17-50.jpg

It is an official method defined in the Material Design guidelines for gestures.

23-04-_2018_11-23-46.jpg

On a grid press an hold the finger on a cell [1] and wait. The layout canges slightly to indiacte the dragmode and then the drag can start [2] without lifting the finger across the grid. The cells will be selected as seen at [3].
An attempt to create this function with CustomListView was not successful since the layout change in the transition from longlick to touch couldn't be achieved. The Gesture library and Klaus's example were considered but somehow didn't work in this case.

A testproject is enclosed where a "finger lift" is needed between longclick-layoutchange-drag.
23-04-_2018_11-21-47.jpg

It would be helpful if someone could help to get a grip on the MD "Long-press drag" gesture.
 

Attachments

  • fredodragsel_15.zip
    19.4 KB · Views: 208

udg

Expert
Licensed User
Longtime User
A DraggableView lets you drag a view around easily; then you could implement the "drop" depending on your project.
I did something similar back in 2014 with my "15 Tiles" game.
Although working, what I described above is not the MD drag gesture you're asking for.

About xCLV: I modified original code from version 1.54 to have a swipe left/right gesture and a long click one. At the moment they are just for the vertical orientation because I needed just that for my project.
 
Upvote 0
Top