Glide加载圆形图片,View是de.hdodenhof.circleimageview.CircleImageView
废话不多说,直接怼解决方案:
public static void loadCircleImage(Context context, final ImageView imageView, String url) { RequestOptions options = new RequestOptions() .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .error(R.drawable.error) .priority(Priority.HIGH); RequestBuilder<Drawable> requestBuilder = Glide.with(context) .load(url); requestBuilder.apply(options) .thumbnail(Glide.with(context).load(url)) // .transition(DrawableTransitionOptions.withCrossFade()) .into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { imageView.setImageDrawable(resource); } }); }
需要添加
.into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { imageView.setImageDrawable(resource); } }