@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.BLACK);
canvas.clipRect(500, 500, 700, 1000);
canvas.drawColor(Color.RED);
}
绘制裁剪举行后,在裁剪区域绘制才会生效,其他的部分不会生效
效果
如果不设置裁剪区域
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.BLACK);
canvas.drawColor(Color.RED);
}