美文网首页
RecyclerView调用notifyDataSetChang

RecyclerView调用notifyDataSetChang

作者: Gao秋 | 来源:发表于2020-06-17 16:36 被阅读0次

因为recyclerView默认设置的动画DefaultItemAnimator造成的,
DefaultItemAnimator继承自SimpleItemAnimator,里面有个方法是
public void setSupportsChangeAnimations(boolean supportsChangeAnimations) {
mSupportsChangeAnimations = supportsChangeAnimations;
}

只要设置为false,就可以不显示动画了,也就解决了闪烁问题。
代码其实就一句话:
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
转载自:
https://www.jianshu.com/p/421cca724958

相关文章

网友评论

      本文标题:RecyclerView调用notifyDataSetChang

      本文链接:https://www.haomeiwen.com/subject/hsmsxktx.html