android.graphics.drawable.TransitionDrawable无法转换为com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable [英] android.graphics.drawable.TransitionDrawable cannot be cast to com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable
本文介绍了android.graphics.drawable.TransitionDrawable无法转换为com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已使用以下代码将远程图像加载到ImageView
I have loaded remote image to ImageView
using below code
Glide.with(context)
.load(imageUrl)
.placeholder(R.drawable.placeholderImage)
.into(holder.wallPaperImageView);
现在我想从imageview获取位图
Now I want to get the bitmap from imageview
Bitmap bitmap = ((GlideBitmapDrawable)holder.wallPaperImageView.getDrawable()).getBitmap();
但在代码行上方抛出以下异常:
but above line of code throws below exception:
java.lang.ClassCastException: android.graphics.drawable.TransitionDrawable无法转换为 com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable
java.lang.ClassCastException: android.graphics.drawable.TransitionDrawable cannot be cast to com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable
该如何解决?
推荐答案
使用此代替:
Bitmap bmp = ((GlideBitmapDrawable)holder.wallPaperImageView.getDrawable().getCurrent()).getBitmap();
或
Glide
.with(this)
.load(a.getAlbum_artwork())
.asBitmap()
.into(new SimpleTarget<Bitmap>(300,300) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
setBackgroundImage(resource);
}
});
这篇关于android.graphics.drawable.TransitionDrawable无法转换为com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文