You can try doing this:
- Copy
android.support.v4.graphics.drawable.RoundedBitmapDrawable
and android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory
to your project, with different names (don't forget to change the package name and fix all imports/etc)
- Edit the
public void draw(Canvas canvas)
method by replacing the drawRoundRect
method call (line 264) with one of the solutions from this thread.
- Use your new class!
Tried adapting Durza007's solution, which is the easiest, however it didn't work for me.
I ended up using Mohammad Mahtabi's solution: added his public static Path RoundedRect()
to my CustomRoundedBitmapDrawable
class, and replaced drawRoundRect
with
Path path = RoundedRect(0, 0, mDstRect.width() , mDstRect.height(),
mCornerRadius, mCornerRadius, true, true, false, false);
canvas.drawPath(path, mPaint);
Here, true, true, false, false
means that the top left and right corners are rounded. It would be wise to make these parameters configurable in HalfRoundedBitmapDrawable
to reuse the class later on.
Tested myself on 4.4 (KitKat), works like a charm.