给网络图片设置圆角会导致闪烁 RequestOptions options = RequestOptions.circleCropTransform(); Glide.with(view.getContext()) .load(url) .apply(options) .placeholder(placeholder) .diskCacheStrategy(DiskCacheStrategy.ALL) .skipMemoryCache(true) .into(view);
有两种修改方式
第一:直接将skipMemoryCache设置为false,但是可能会导致再次更新图片的时候不更新,直接从缓存中获取
第二:设置
.into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { view.setImageDrawable(resource); } });
从Glide源码中可以看到调用maybeUpdateAnimatable,执行这个动画可能是导致闪烁的原因,所以直接重写onResourceReady,不执行动画,避免闪烁