我想改变我装有圆角的图像。
I would like to change an image I loaded to have round corners.
任何提示,教程,你知道吗?
Any hints, tutorials, best practices you know of?
为什么不使用clipPath?
Why not use clipPath?
protected void onDraw(Canvas canvas) {
Path clipPath = new Path();
float radius = 10.0f;
float padding = radius / 2;
int w = this.getWidth();
int h = this.getHeight();
clipPath.addRoundRect(new RectF(padding, padding, w - padding, h - padding), radius, radius, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}