iam使用textureView绘制json数据,比如波形,它的绘制完美,但我想更新绘图的背景onTouch
在ACTION_MOVE
但是我面对并且问题它使我的绘图轻弹这个gif图像当然,用手指移动视图时的问题
这个代码更新了背景颜色
case MotionEvent.ACTION_MOVE:
Canvas canvasX = null;
try {
canvasX = surface.lockCanvas(null);
synchronized (surface) {
canvas.save();
mPaint2.setColor(Color.RED);
mPaint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
canvasX.drawRect(0, 0, event.getRawX() + dX, canvasX.getHeight(),mPaint2);
mPaint.setColor(Color.GREEN);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
canvasX.drawRect(event.getRawX() + dX, 0, canvasX.getWidth(), canvasX.getHeight(),mPaint);
canvas.restore();
}
} finally {
if (canvasX != null) {
surface.unlockCanvasAndPost(canvasX);
}
}
this.animate()
.x(event.getRawX() + dX)
.setDuration(0)
.start();
break;
任何人都知道这里发生了什么以及如何解决它