Closed ZhaoSiBo closed 5 years ago
在MaskView的ondraw方法里,有一段代码是这样的 if (!mOverlayTarget) { switch (mStyle) { case Component.ROUNDRECT: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; case Component.CIRCLE: mEraserCanvas.drawCircle(mTargetRect.centerX(), mTargetRect.centerY(), mTargetRect.width() / 2, mEraser); break; default: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; } canvas.drawBitmap(mEraserBitmap, 0, 0, null); } } 判读的标志位是我们设置的是否覆盖目标控件,如果设置遮盖的话,那么整个遮罩讲覆盖整个屏幕,但是在我尝试之后发现并没有,出现想要的效果,而是屏幕上失去了遮盖效果。但遮罩用的图片还是会出现的,经过查看,发现在MaskView的onDraw方法中缺少必要的绘制 if (!mOverlayTarget) { switch (mStyle) { case Component.ROUNDRECT: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; case Component.CIRCLE: mEraserCanvas.drawCircle(mTargetRect.centerX(), mTargetRect.centerY(), mTargetRect.width() / 2, mEraser); break; default: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; } canvas.drawBitmap(mEraserBitmap, 0, 0, null); }else{ canvas.drawBitmap(mEraserBitmap, 0, 0, null); } } 在绘制的if语句后把else加上,这句 canvas.drawBitmap(mEraserBitmap, 0, 0, null); 用来绘制灰色的背景
新版本已fix,谢谢反馈
在MaskView的ondraw方法里,有一段代码是这样的 if (!mOverlayTarget) { switch (mStyle) { case Component.ROUNDRECT: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; case Component.CIRCLE: mEraserCanvas.drawCircle(mTargetRect.centerX(), mTargetRect.centerY(), mTargetRect.width() / 2, mEraser); break; default: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; } canvas.drawBitmap(mEraserBitmap, 0, 0, null); } } 判读的标志位是我们设置的是否覆盖目标控件,如果设置遮盖的话,那么整个遮罩讲覆盖整个屏幕,但是在我尝试之后发现并没有,出现想要的效果,而是屏幕上失去了遮盖效果。但遮罩用的图片还是会出现的,经过查看,发现在MaskView的onDraw方法中缺少必要的绘制 if (!mOverlayTarget) { switch (mStyle) { case Component.ROUNDRECT: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; case Component.CIRCLE: mEraserCanvas.drawCircle(mTargetRect.centerX(), mTargetRect.centerY(), mTargetRect.width() / 2, mEraser); break; default: mEraserCanvas.drawRoundRect(mTargetRect, mCorner, mCorner, mEraser); break; } canvas.drawBitmap(mEraserBitmap, 0, 0, null); }else{ canvas.drawBitmap(mEraserBitmap, 0, 0, null); } } 在绘制的if语句后把else加上,这句 canvas.drawBitmap(mEraserBitmap, 0, 0, null); 用来绘制灰色的背景