How to use RoundedBitmapDrawable

2019-03-08 03:04发布

Has anyone managed to use RoundedBitmapDrawable? Correct me if I'm wrong, but to my understanding, it makes a circular image from a regular rectangular image.

What I've tried so far is this

RoundedBitmapDrawable.createRoundedBitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), iconResource))

What I tried to achieve: transform any image to a circular image and show it using an ImageView.

In case I mixed things up and all that I said is non-sense. Is it possible (or simpler) to do it with any of the new framework? (Android L or new Support Library)

7条回答
做个烂人
2楼-- · 2019-03-08 03:49

The current way RoundedBitmapDrawable works on non-square images is not so well. It makes the content stretch.

I suggest using an alternative for this, as I've written here: How to have a circular, center-cropped imageView, without creating a new bitmap?

查看更多
登录 后发表回答