【发布时间】:2012-12-19 06:07:33
【问题描述】:
我正在制作一个图片裁剪应用程序。
但是 Galaxy nexus 存在一些问题。
Region.Op.DIFFERENCE 不起作用。
Desire(2.3.3) 和 GalaxyNexus(4.1) 模拟器运行良好。
但不仅适用于 GalaxyNexus 真手机
请看代码... 这是一个 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);
}
【问题讨论】:
标签: android android-canvas ondraw