Set Background Image to Relative Layout using Glide in Android

后端 未结 7 576
逝去的感伤
逝去的感伤 2020-12-24 11:33

How can I do this using Glide? I want to cache image to use it another time also. Thanks in advance.

7条回答
  •  青春惊慌失措
    2020-12-24 12:15

    Here's the code for Kotlin

    • Glide 4.9.x
    • Since the SimpleTarget is deprecated now we have to use CustomTarget as below
    Glide.with(this).load(UCrop.getOutput(data)).into(object : 
                            CustomTarget() {
                            override fun onLoadCleared(placeholder: Drawable?) {
                                TODO("Not yet implemented")
                            }
    
                            override fun onResourceReady(
                                resource: Drawable,
                                transition: Transition?
                            ) {
                                ib_pet_profile_image.background=resource
                            }
    
                        })
    

提交回复
热议问题