罗曼盖伊的圆角形象
使用使用 Canvas.drawRoundRect() 绘制圆角矩形的自定义 Drawable。诀窍是使用带有 BitmapShader 的 Paint 来用纹理而不是简单的颜色填充圆角矩形。
http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/
样本可以下载@https ://docs.google.com/file/d/0B3dxhm5xm1sia2NfM3VKTXNjUnc/edit?pli= 1
这是另一个链接
如何制作带圆角的 ImageView?
另一个链接
http://ruibm.com/?p=184
public class ImageHelper {
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
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 = pixels;
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;
}
}