誰か使用できましたかRoundedBitmapDrawable
? 間違っていたら訂正してください。私の理解では、通常の長方形の画像から円形の画像を作成します。
これまで試したのはこれです
RoundedBitmapDrawable.createRoundedBitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), iconResource))
私が実現しようとしたこと: 任意の画像を円形画像に変換し、ImageView を使用して表示します。
私が混乱して、私が言ったことはすべてナンセンスだった場合に備えて。新しいフレームワークのいずれかでそれを実行することは可能(または簡単)ですか?(Android Lまたは新しいサポートライブラリ)
ベストアンサー1
コーナーの半径を設定する必要があります。
Resources res = getResources();
Bitmap src = BitmapFactory.decodeResource(res, iconResource);
RoundedBitmapDrawable dr =
RoundedBitmapDrawableFactory.create(res, src);
dr.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f);
imageView.setImageDrawable(dr);