android - How to implement ItemAnimator of RecyclerView to disable the animation of notifyItemChanged -
in project need disable "change" animation of recyclerview
while notifyitemchanged
.
i investigated in source of recyclerview
, had overridden android.support.v7.widget.defaultitemanimator
below:
private static class itemanimator extends defaultitemanimator { @override public boolean animatechange(recyclerview.viewholder oldholder, recyclerview.viewholder newholder, int fromx, int fromy, int tox, int toy) { if(oldholder != null) { oldholder.itemview.setvisibility(view.invisible); dispatchchangefinished(oldholder, true); } if(newholder != null) { dispatchchangefinished(newholder, false); } return false; } }
but not sure if match spec of google document: recyclerview.itemanimator.animatechange
according understanding source code, if not override method properly, oldholder will not recycled.
please me figure out how override animatechange
in correct way.
i have found correct solution remove animatechange.
it's simple. google has implemented functionality.
((simpleitemanimator) recyclerview.getitemanimator()).setsupportschangeanimations(false);
documentation: setsupportschangeanimations
Comments
Post a Comment