2

Everything worked well before starting using RoundedBitmapDrawable to round Bitmap's corners.

After starting using RoundedBitmapDrawable, I'm getting:

java.lang.ClassCastException: android.support.v4.graphics.drawable.RoundedBitmapDrawable21 cannot be cast to android.graphics.drawable.BitmapDrawable

Code:

BitmapDrawable bitmapDrawable = ((BitmapDrawable) imageView.getDrawable());
Baris Demiray
  • 1,539
  • 24
  • 35
Miko Diko
  • 944
  • 1
  • 13
  • 33

1 Answers1

-3

There is not a hierarchical link between these two types except that they share the same parent. Instead, you can check the type of drawable at runtime and cast accordingly,

if (imageView.getDrawable() instanceof android.support.v4.graphics.drawable.RoundedBitmapDrawable) {
    RoundedBitmapDrawable drawable = (RoundedBitmapDrawable) imageView.getDrawable();
    Bitmap roundedBitmap = drawable.getBitmap();
    // ...
}
Baris Demiray
  • 1,539
  • 24
  • 35