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

后端 未结 4 560
时光说笑
时光说笑 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:43

    In Glide 4.9.0 SimpleTarget is deprecated. You can use CustomTarget instead.

    Glide.with(myFragmentOrActivity)
             .load(imageUrl)
             .into(new CustomTarget(100,100) {
    
            @Override
            public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition)
            {
                left.setCompoundDrawablesWithIntrinsicBounds(null, resource, null, null);
            }
    
            @Override
            public void onLoadCleared(@Nullable Drawable placeholder)
            {
                left.setCompoundDrawablesWithIntrinsicBounds(null, placeholder, null, null);
            }
        });
    

提交回复
热议问题