RecyclerView blinking after notifyDatasetChanged()

前端 未结 18 1712
悲&欢浪女
悲&欢浪女 2020-12-07 16:20

I have a RecyclerView which loads some data from API, includes an image url and some data, and I use networkImageView to lazy load image.

@Override
public vo         


        
18条回答
  •  独厮守ぢ
    2020-12-07 16:52

    try this to disable the default animation

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

    this the new way to disable the animation since android support 23

    this old way will work for older version of the support library

    recyclerView.getItemAnimator().setSupportsChangeAnimations(false)
    

提交回复
热议问题