如何制作带有圆角的ImageView?
在Android中,默认情况下,ImageView是一个矩形。 如何在ImageView中使其成为一个圆角矩形(将Bitmap的所有4个角都切掉为圆角矩形)? #1楼 非常感谢您首先回答。 这是修改后的版本,可将矩形图像转换为正方形图像(并四舍五入),并通过填充颜色作为参数。 public static Bitmap getRoundedBitmap(Bitmap bitmap, int pixels, int color) { Bitmap inpBitmap = bitmap; int width = 0; int height = 0; width = inpBitmap.getWidth(); height = inpBitmap.getHeight(); if (width <= height) { height = width; } else { width = height; } Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(output); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, width, height); final