通知数据集更改时,为什么Glide会闪烁ImageView项

编程入门 行业动态 更新时间:2024-10-24 08:25:08
本文介绍了通知数据集更改时,为什么Glide会闪烁ImageView项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将 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项

本文发布于:2023-11-26 17:47:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   数据   ImageView   Glide

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!