问题描述
我为有需要的人共享一个代码,该代码用于绘制相机的SurfaceView,该代码由透明背景上的透明矩形和可选的alpha组成。
欢迎大家做出更好的贡献:)
@Override
protected void onDraw(Canvas canvas) {
mAGPLog.e(this.getClass().getName() + " - onDraw");
canvas.drawColor(Color.argb(128,224,224));
int margin = (int) getResources().getDimension(R.dimen.margin_camera);
int width = getWidth();
int height = getHeight();
mAGPLog.e("width - " + width + " * height - " + height);
int distance = width < height ? width - margin : height - margin;
paint.setColor(Color.CYAN);
paint.setstrokeWidth(strokerWidth);
paint.setStyle(Paint.Style.stroke);
canvas.drawRect(
(width - distance) / 2,(height - distance) / 2,(width + distance) / 2,(height + distance) / 2,paint);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.argb(0,255,255));
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
canvas.drawRect(
(width - distance) / 2 + strokerWidth,(height - distance) / 2 + strokerWidth,(width + distance) / 2 - strokerWidth,(height + distance) / 2 - strokerWidth,paint);
super.onDraw(canvas);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)