vinc3m1 / RoundedImageView

A fast ImageView that supports rounded corners, ovals, and circles.
Other
6.44k stars 1.25k forks source link

TransitionDrawable support #254

Closed carriehall closed 4 years ago

carriehall commented 4 years ago

I am getting the same exception as others when I try to use a transition drawable

java.lang.IllegalArgumentException: width and height must be > 0

I believe it's caused by these lines

if (drawable instanceof ColorDrawable) {
     bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
} else {
     bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
}

TransitionDrawables are returning -1 for the intrinsic sizes, presumably because I am creating them on the fly as they are used for a Picasso placeholder rather than inflated onto the screen already.

If I use a custom class and override getIntrinsicWidth and getIntrinsicHeight with 1, then it seems to work, but it feels hacky and I'm not sure what the repercussions are.