![](/img/trans.png)
[英]How to load GIF image from drawable folder into ImageView using glide?
[英]How can I get drawable from glide? Actually i want to return drawable from glide which load image and put into imageview
这是我的代码:
d.setBounds(15, 8, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d,ImageSpan.ALIGN_BOTTOM) {}
使用最新版本的Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
科特林:
Glide.with(this)
.asBitmap()
.load(imagePath)
.into(object : CustomTarget<Bitmap>(){
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
imageView.setImageBitmap(resource)
}
override fun onLoadCleared(placeholder: Drawable?) {
// this is called when imageView is cleared on lifecycle call or for
// some other reason.
// if you are referencing the bitmap somewhere else too other than this imageView
// clear it here as you can no longer have the bitmap
}
})
位图大小:
如果要使用图像的原始大小,请使用上面的默认构造函数,否则可以传递所需的位图大小
into(object : CustomTarget<Bitmap>(1980, 1080)
Java的:
Glide.with(this)
.asBitmap()
.load(path)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
imageView.setImageBitmap(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.