Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swipe to delete for a custom view not for list item

I want to develop a layout with a very simple ImageView and a Listview binded in a Relativelayout . Now for a better user experience I want to delete the Image view by swiping it left or right same like what is implemented in android Gmail app to delete emails.

Implementing it on a listview item is very simple and there are many tuts and sample codes are available over the internet including the official Google I/O talk on animation and explained in a very good way by Chet Hasse here

https://www.youtube.com/watch?v=YCHNAi9kJI4

but I don't require to implement it on the listview items insted I want to implement it in more generic way. In my case I want the same behaviour for my ImageView item as one view and ListView another . Like shown below

layout

As soon as the ImageView item is deleted the whole ListView should smoothly come on the top.

I have tried many way to implement the same without any success.

Suggest me the approach or some samples to do this which is supported in Gingerbread and above android OS.

like image 999
Piyush Agarwal Avatar asked Mar 25 '14 19:03

Piyush Agarwal


2 Answers

You can use this code:

https://github.com/romannurik/Android-SwipeToDismiss/blob/master/src/com/example/android/swipedismiss/SwipeDismissTouchListener.java

As described in readme this code works for android 14+.

You can use the NineOldAndroids library to support old versions of Android, or use the Jake Wharton's port:

https://github.com/JakeWharton/SwipeToDismissNOA

like image 165
Gabriele Mariotti Avatar answered Oct 20 '22 12:10

Gabriele Mariotti


I looked around and found this helpful. https://github.com/nhaarman/ListViewAnimations

like image 38
karma Avatar answered Oct 20 '22 11:10

karma