GradientDrawable cannot be cast to android.graphics.drawable.BitmapDrawable

 Caused by: java.lang.ClassCastException: android.graphics.drawable.GradientDrawable cannot be cast to android.graphics.drawable.BitmapDrawable

出错代码:

mThumbBitmap  =((BitmapDrawable)getResources().getDrawable(R.drawable.circle)).getBitmap();

类型不同,导致讲drawable转为bitmap出错。解决方案:

private Bitmap drawableToBitamp(Drawable drawable)
{
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
   return Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
}

你可能感兴趣的:(GradientDrawable cannot be cast to android.graphics.drawable.BitmapDrawable)