android-advancedrecyclerview icon indicating copy to clipboard operation
android-advancedrecyclerview copied to clipboard

Group collapse animation

Open NSouth opened this issue 8 years ago • 3 comments

I've been using a custom implementation of this library for a while (so just downloading the latest version would overwrite my customizations).

See the animated GIF below. When collapsing, the "Lab" group disappears and then shows up under "Exams" instead of smoothly moving up beneath it. This used to be a much smoother transition and I'm wondering if someone can help me figure out what's changed in recent Android updates and which classes from this library I need to update to correct this. I've already gone through and tried updating the animator classes, but to no avail. I'd appreciate any tips. Thanks.

Animation of behavior - GIF

NSouth avatar May 11 '16 23:05 NSouth

Hi. Which version of the old libraries have you been using?

  • support-v7-recyclerview
  • Advanced RecyclerView

I think this unwanted animation is related to item change animations. The RecyclerView has been changed some times around the change animation. Here is a picked up important revision history of it;


Android Support Library, revision 23.1.0 (October 2015)

Changes for v7 recyclerview library:

  • Added an improved animation API to the ItemAnimator class for better customizations: Change animations no longer enforce two copies of the ViewHolder object, which enables item content animations. Also, the ItemAnimator object decides whether it wants to reuse the same ViewHolder object or create a new one. The new information record API gives the ItemAnimator class the flexibility to collect data at the correct point in the layout lifecycle. This information is later passed into the animate callbacks. Provided an easy transition plan for this backward-incompatible API change:

  • If you’ve previously extended the ItemAnimator class, you can change your base class to SimpleItemAnimator and your code should work as before. The SimpleItemAnimator class provides the old API by wrapping the new API. Some methods were removed from the ItemAnimator class. The following code will no longer compile: recyclerView.getItemAnimator().setSupportsChangeAnimations(false) You can replace it with:

    ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
       ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    

Android Support Library, revision 23.2.0 (February 2016)

Changes for v7 RecyclerView library:

  • When updating a RecyclerView.ViewHolder with payload information, DefaultItemAnimator now disables change animations.

source: http://developer.android.com/tools/support-library/index.html#revisions

Thanks

h6ah4i avatar May 15 '16 13:05 h6ah4i

Thanks for the reply. I haven't been able to get it back to working as smoothly as it did before and, but I played with the following and, while the remove animation is no longer pretty, at least it's short and doesn't bother me as much anymore. I don't have the time to dig into this any deeper, although I'm sure there's a way to make this work as it once did. animator.setMoveDuration(150); animator.setChangeDuration(200); animator.setRemoveDuration(40);

NSouth avatar May 17 '16 22:05 NSouth

I was having the same problem but managed to fix it. I had android:layout_height="wrap_content" on my RecyclerView. With match_parent the remove animation quirk no longer happens.

This depends on your use of course. For my layout, match_parent worked.

kakai248 avatar Feb 26 '18 11:02 kakai248