Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Android listview opening gesture

This is an open question about Android ListViews, Gestures and Animations. I'm really not familiar with the gestures in Android, so I'm just looking for ideas and grey matter on this.

Here's two screenshot and a video examples of the effect on what I'm trying to cogitate. Consider taking a look at the video, it's really worth it.

enter image description here

enter image description here

The screenshots are from an iOS open source project found here.

The question is, how would you implement a "listview opening" gesture like the one I see more and more often in iPhone/iPad apps, but for Android ?

Edit 1, idea 1:

Okay first idea, AFAIK the Pinch gesture is somehow like a dragging gesture, so I guess we can get the X and Y coordinates of the two fingers on the screen?

Next, the answer to this question may help, the basic idea is:

Get the index position of the first visible item in the list

Get the index position of the last visible item in the list

Iterate from the first index to the last with the getChildAt function

For each child, call the getLocationOnScreen method to get coordinates of the current iterated item

After that, some comparison between the pinch gesture coordinates and each item coordinates might be done inside the loop to get the two items between which the new row must me inserted.

Performances considerations appart I think it could work, but maybe there's a simpler way to get those two items(?).

Who's next? :)

Update:

Thanks for the tip @rhlnair, I take this occasion to tell everybody that I started to work on this on my spare time and you are more then welcome to help on this.

The project is at https://github.com/arnaudbos/Android-GestureListView. I started two different implementations on two different branches, and would enjoy anybody to create a new branch.

I have something really encouraging in branch "attemp-via-scale-gesture-detector" but some side effects from the ListView.

Come on folks!

like image 492
Arnaud Avatar asked Nov 14 '22 10:11

Arnaud


1 Answers

seems to be a challenging idea..

i think some of the effect in clear app like dragging a selected row up/down can be taken from

https://github.com/commonsguy/cwac-touchlist

like image 100
rhlnair Avatar answered Nov 16 '22 03:11

rhlnair