-1

i would like to know how to view the image in a circle view ?! like the imageview in instagram or like the other applications that can be put an imageview . In fact i would like to control by display the image in a circle or square .

user3077582
  • 91
  • 1
  • 6

2 Answers2

1

Just check the below code

 public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
    bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);

final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = 12;

paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);

return output;

}

Ameer
  • 2,709
  • 1
  • 28
  • 44
  • could you tell me where I put this code exactly ? I mean I want to open an image from my phone and choose it , after that I want a specific size of the imageview and if its not I crop it and after that it shows it in a circle view. Hopefully didn't its not too much :) – user3077582 Feb 24 '14 at 19:22
0

please refer to this answer here
and please five me some feedback

Hope that Helps .

Community
  • 1
  • 1