public class RoundCornerImageView extends android.support.v7.widget.AppCompatImageView {
public RoundCornerImageView(Context context) {
super(context);
}
public RoundCornerImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RoundCornerImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
Path clipPath = new Path();
int w = this.getWidth();
int h = this.getHeight();
clipPath.addRoundRect(new RectF(0, 0, w, h), w/2, h/2, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
}
android 圆形倒角img
最新推荐文章于 2022-05-12 14:18:49 发布