我正在制作一个应用它的图片裁剪。
但 Galaxy nexus 存在一些问题。
Region.Op.DIFFERENCE 不起作用。
Desire(2.3.3) 和 GalaxyNexus(4.1) 模拟器运行良好。
但不仅适用于 GalaxyNexus Real Phone
请查看代码...这是一个 onDraw 覆盖的方法,它是扩展的 imageview
@override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//all rectangle
getDrawingRect(viewRect);
//small rectangle
getDrawingRect(smallRect);
smallRect.left += 100;
smallRect.right -= 100;
smallRect.bottom -= 200;
smallRect.top += 200;
// paint color setting to transparency black
mNoFocusPaint.setARGB(150, 50, 50, 50);
// All Rectangle clipping
canvas.clipRect(viewRect);
// Small Rectangle clipping
canvas.clipRect(smallRect, Region.Op.DIFFERENCE);
// Draw All Rectangle transparency black color it's except small rectangle
canvas.drawRect(viewRect, mNoFocusPaint);
}