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 .
Asked
Active
Viewed 153 times
-1
-
did u tried any thing ? – Feb 24 '14 at 10:32
-
oh thats awesome ! thanx body – user3077582 Feb 24 '14 at 10:34
2 Answers
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