Is it possible to use Glide to download image to load into a TextView?

后端 未结 4 554
时光说笑
时光说笑 2021-02-06 01:31

In my app I download an image from an URL and set it into an ImageView through Glide, however, I\'m trying to remove a few unnecessary layouts, so is it possible to use Glide to

4条回答
  •  野性不改
    2021-02-06 01:54

    Using Glide 4.7.1:

    Glide.with(context)
         .load(someUrl)
         /* Because we can*/
         .apply(RequestOptions.circleCropTransform())
         /* If a fallback is not set, null models will cause the error drawable to be displayed. If
          * the error drawable is not set, the placeholder will be displayed.*/
         .apply(RequestOptions.placeholderOf(R.drawable.default_photo))
         .into(new SimpleTarget() {
             @Override
             public void onResourceReady(@NonNull Drawable resource,
                     @Nullable Transition transition) {
                 /* Set a drawable to the left of textView */
                 textView.setCompoundDrawablesWithIntrinsicBounds(resource, null, null, null);
             }
    });
    

提交回复
热议问题