我使用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;
任何人都知道这里发生了什么以及我该如何解决它