RecyclerView调用notifyItemChanged闪烁问题
来源:互联网 发布:js实现rsa加密算法 编辑:程序博客网 时间:2024/05/16 06:19
RecyclerView调用notifyItemChanged闪烁问题相信很多人都遇到过。
那是因为recyclerView默认设置的动画DefaultItemAnimator造成的,
DefaultItemAnimator继承自SimpleItemAnimator,里面有个方法是
/** * Sets whether this ItemAnimator supports animations of item change events. * If you set this property to false, actions on the data set which change the * contents of items will not be animated. What those animations do is left * up to the discretion of the ItemAnimator subclass, in its * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} implementation. * The value of this property is true by default. * * @param supportsChangeAnimations true if change animations are supported by * this ItemAnimator, false otherwise. If the property is false, * the ItemAnimator * will not receive a call to * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, * int)} when changes occur. * @see Adapter#notifyItemChanged(int) * @see Adapter#notifyItemRangeChanged(int, int) */ public void setSupportsChangeAnimations(boolean supportsChangeAnimations) { mSupportsChangeAnimations = supportsChangeAnimations; }
只要设置为false,就可以不显示动画了,也就解决了闪烁问题。
代码其实就一句话。
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
3 1
- RecyclerView调用notifyItemChanged闪烁问题
- 解决recyclerview notifyItemChanged 闪烁问题
- recyclerView调用notifyItemChanged导致屏幕闪烁的问题
- 使用RecyclerView notifyItemChanged()出现图片闪烁问题解决
- 关于RecyclerView notifyItemChanged() 刷新下标错误问题
- android RecyclerView notifyItemChanged无效的问题
- Recyclerview默认动画导致调用notifyItemChanged(position)更新时ViewHolder变动引起的问题
- 解决notifyitemchanged 闪烁
- RecyclerView通过notifyItemChanged方法更新item时避免闪烁的方法
- RecyclerView notifyItemChanged 后 item 闪动
- RecyclerView notifyItem闪烁的问题
- RecyclerView notifyItem闪烁的问题
- RecyclerView调用notifyDataSetChanged刷新,图片闪烁
- Recyclerview使用notifyitemchanged方法会回到顶部
- Android RecyclerView更新子项目notifyItemChanged
- RecyclerView notifyDataSetChanged 图片闪烁的问题
- 调用InvalidateRect闪烁的问题
- 《android编程权威指南》RecyclerView的notifyItemChanged()方法使用
- Linux统计文件夹中文件的个数
- 【Android】Gallery实现选中图片变大,两侧没选中图片变小
- Token在android中的使用
- Android图片加载框架Glide使用总结
- 8大排序算法图文讲解
- RecyclerView调用notifyItemChanged闪烁问题
- linux下的gedit命令使用方法与技巧
- 1.3 起步 - Git 基础
- 7 Python struct模块-深入学习
- Web前端面试指导(三十五):call() 和 apply() 的区别?
- okhttp的简单封装
- Thread.currentThread().getContextClassLoader().getResourceAsStream
- .bat批处理(一):@echo off
- 至我们沉迷的二次元