java.lang.Class Cast Exception: com.lidroid.xutils.bitmap.core.Async Drawable cannot be cast to andr

来源:互联网 发布:大数据底层架构 编辑:程序博客网 时间:2024/06/07 03:34

如果使用xutils加载图片的朋友可能有的时候用上这种圆图处理会报异常

在其中加上这个判断就OK了

  if(drawable instanceof BitmapDrawable){          b =  ((BitmapDrawable)drawable).getBitmap() ;      }else if(drawable instanceof AsyncDrawable){          b = Bitmap                   .createBitmap(                   getWidth(),                   getHeight(),                   drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888                   : Bitmap.Config.RGB_565);                   Canvas canvas1 = new Canvas(b);                   // canvas.setBitmap(bitmap);                   drawable.setBounds(0, 0, getWidth(),                   getHeight());                   drawable.draw(canvas1);       }  


0 0