我正在将 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 problem thank 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项
发布评论