我使用 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.
如果我使用下面的代码:
If I use the code below:
Glide .with(context) .load(filepath) .dontAnimate() .into(imageview);然后项目 ImageView 不再闪烁(使用缓存).
Then the item ImageView does not blink anymore (using cache).
我想动态更新 item 视图,所以我禁用了 glide 缓存.
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); } });更多推荐
为什么在notifydatasetchanged时Glide会闪烁项目ImageView
发布评论