如何从滑行中绘制?实际上我想从加载图像并将其放入imageview的滑行中返回drawable [英] How can I get drawable from glide? Actually i want to return drawable from glide which load image and put into imageview
本文介绍了如何从滑行中绘制?实际上我想从加载图像并将其放入imageview的滑行中返回drawable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
d.setBounds(15, 8, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d,ImageSpan.ALIGN_BOTTOM) {}
推荐答案
使用最新版本的Glide
Use the latest version of 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
}
})
位图大小:
如果要使用图像的原始大小,请使用上面的默认构造函数,否则可以将所需的大小传递给位图
if you want to use the original size of the image use the default constructor as above, else You can pass your desired size for 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) {
}
});
这篇关于如何从滑行中绘制?实际上我想从加载图像并将其放入imageview的滑行中返回drawable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文