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

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

    Here is a simple example of how to do using Kotlin.

    GlideApp.with(context)
                .load("url")
                .placeholder(R.drawable.your_placeholder)
                .error(R.drawable.your_error_image)
                .into(object : CustomTarget(100, 100) {
                    override fun onLoadCleared(drawable: Drawable?) {
                        header.companyLogoJob.setCompoundDrawablesWithIntrinsicBounds(drawable,null,null,null)
                    }
    
                    override fun onResourceReady(res: Drawable, transition: com.bumptech.glide.request.transition.Transition?) {
                        header.companyLogoJob.setCompoundDrawablesWithIntrinsicBounds(res,null,null,null)
                    }
    
                })
    

提交回复
热议问题