问题描述
我正在将 Glide 3.7.0 与RecyclerView
一起使用.刷新(调用notifyDataSetChanged
)时,项目视图始终闪烁.
I am using Glide 3.7.0 with RecyclerView
. The item view always blinks when refreshing (calling notifyDataSetChanged
).
这是我的代码:
Glide
.with(context)
.load(filepath)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.dontAnimate()
.into(imageview);
当我不使用缓存时,调用notifyDataSetChanged
方法并且Glide尚未完成加载位图时,ImageView
的位图为空.
When I use no cache, the ImageView
has a null Bitmap when notifyDataSetChanged
method is called and Glide hasn't finished loading the bitmap.
如果我使用以下代码:
Glide
.with(context)
.load(filepath)
.dontAnimate()
.into(imageview);
然后ImageView
项不再闪烁(使用缓存).
Then the item ImageView
does not blink anymore (using cache).
我想动态更新项目视图,因此我禁用了滑行缓存.
I want to update the item view dynamically, so I disable the glide cache.
是否有解决此眨眼错误的解决方案?
Are there any solutions to solve this blink bug?
非常感谢!
推荐答案
经过多次尝试,只需使用SimpleTarget即可解决我的问题谢谢!
After my many tries, just use SimpleTarget solved my problemthank you!
Glide
.with(context)
.load(filepath)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.dontAnimate()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
// TODO Auto-generated method stub
holder.mItemView.setImageBitmap(arg0);
}
});
这篇关于通知数据集更改时,为什么Glide会闪烁ImageView项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!