How to implement ItemAnimator of RecyclerView to disable the animation of notifyItemChanged

前端 未结 8 1159
有刺的猬
有刺的猬 2020-12-13 03:20

In my project I need disable the \"change\" animation of RecyclerView while notifyItemChanged.

I investigated in the source of Recycl

8条回答
  •  情书的邮戳
    2020-12-13 04:14

    The easiest solution is to extend DefaultItemAnimator and set setSupportsChangeAnimations to false right in the constructor:

    public class DefaultItemAnimatorNoChange extends DefaultItemAnimator {
        public DefaultItemAnimatorNoChange() {
            setSupportsChangeAnimations(false);
        }
    }
    

提交回复
热议问题