iPaulPro / Android-ItemTouchHelper-Demo

Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView.
Apache License 2.0
2.51k stars 500 forks source link

Zoom Animation on Dragging #13

Open goktugerce opened 8 years ago

goktugerce commented 8 years ago

I have been wondering if I can add a zoom animation to my items on RecyclerView. My item layout has only ImageView and I want to be able to enlarge image to its original size on touch and return it to its scaled size after touch ends. I have tried several stuff but could not manage to find a solution. It either blocks the dragging or does not go back to scaled size after I stop pressing.

If I add a touch listener with ACTION_DOWN and ACTION_UP cases, I can use a scale animation but can't move the item. If I do it in onMove method, it enlarges after the drag, not on touch and it doesn't shrink back. Any suggestion?

MrLepage commented 7 years ago

In your ViewHolder which implements ItemTouchHelperViewHolder you need to override onItemSelected and onItemClear.

Start a scale animation in onItemSelected and reverse in onItemClear and you are done :)