0

I am using xamarin android native for my application development. I rounded the image from bitmap on the ImageView using the following code.

<ImageView
      android:id="@+id/proimg"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/pro1" />

in code,

imgpro.SetImageBitmap(bitmap);
imgpro.SetImageDrawable(ImageHelper.getRoundedCornerImage(bitmap, 120));

public class ImageHelper
{

            public static Android.Support.V4.Graphics.Drawable.RoundedBitmapDrawable getRoundedCornerImage(Bitmap thePic, int cornerRadius)
            {
                Android.Support.V4.Graphics.Drawable.RoundedBitmapDrawable dr = Android.Support.V4.Graphics.Drawable.RoundedBitmapDrawableFactory.Create(null, thePic);
                dr.CornerRadius = cornerRadius;
                return dr;
            }
}

But the image comes with empty space like below(empty spaces highlights with red mark):enter image description here

The image does not adjust based on the ImageView.

Can anyone help me to resolve this issue.

Thanks in Advance

1 Answers1

1

Try this one:

<ImageView
       android:id="@+id/proimg"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:scaleType="centerCrop"
       android:adjustViewBounds="true
       android:src="@drawable/pro1" />
Taier
  • 2,109
  • 12
  • 22
  • Hi Taier, Thank you for your immediate reply. But it is not working. Could please advice me anyother solution? – Arun manthiram Jul 25 '17 at 07:17
  • I'll advise you to round image using layout, rather than a bitmap. The first answer to that question explains how to do it https://stackoverflow.com/questions/22105775/imageview-in-circular-through-xml – Taier Jul 25 '17 at 08:51