使用
RequestListener<String, GlideDrawable>
这为您提供了一个可绘制的:
(
GlideDrawable
也是
Drawable
).
Glide.with(activity)
.load("...")
.listener(object : RequestListener<String, GlideDrawable> {
override fun onResourceReady(resource: GlideDrawable?, model: String?, target: Target<GlideDrawable>?, isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
// GlideDrawable extends Drawable :)
}
override fun onException(e: Exception?, model: String?, target: Target<GlideDrawable>?, isFirstResource: Boolean): Boolean = false
})
您需要删除
asBitmap()
呼叫
我的代码是kotlin,因为我从我的项目中复制粘贴了它,但我相信您可以理解它。