RoundedImageView
RoundedImageView copied to clipboard
Question/bug: why do I get a bad rounded rectangle using RoundedDrawable ?
I use this :
ImageView iv = (ImageView) findViewById(R.id.image);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.photo1);
final RoundedDrawable roundedDrawable = RoundedDrawable.fromBitmap(bitmap);
roundedDrawable.setCornerRadius(0,100,100,0);
iv.setImageDrawable(roundedDrawable);
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.makeramen.roundedimageview.example.MainActivity">
<ImageView
android:id="@+id/image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:scaleType="centerCrop"/>
</FrameLayout>
And get this:
Even when I set wrap_content for both width and height, I get this (not quite rounded corners) :
How come?
Cannot reproduce this bug. Everything is well here with your code. Using roundedimageview:2.2.1
.