Swipe to delete for a custom view, not a list item.

I want to develop a layout with a very simple ImageView and Listview linked in Relativelayout. Now, for a better user interface, I want to remove the image view by checking it left or right, like what was implemented in the Android Android application for deleting letters.

Implementing it in a listview element is very simple, and there are many links and sample code available on the Internet, including official talk about Google input / output in animations, and Chet Hasse is very well explained here.

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

but I do not require it to be implemented in listview elements, which I want to implement in a more general way. In my case, I want the same behavior for the ImageView element as one view, and ListView another. As below

layout

Once the ImageView element has been removed, the entire ListView should smoothly exit at the top.

I tried many ways to implement the same without any success.

Suggest me an approach or a few examples for this, which is supported on Gingerbread and above Android OS.

+7
android android-animation
source share
4 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 older versions of Android, or use the Jake Wharton port:

https://github.com/JakeWharton/SwipeToDismissNOA

+7
source share

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

+1
source share

I implemented a custom ViewGroup that takes one child and allows you to drag it to the left with a callback after the swipe is complete. My intention was for it to work just like in RecyclerView. Works well in LinearLayout with animateLayoutChanges = true and sets the visibility of GONE in the callback.

Here: https://gist.github.com/darnmason/38a1a5178a06470202784050f4dc1cdf

0
source share

All you need is this library: https://github.com/timroes/EnhancedListView

-2
source share

All Articles