android textureVIew轻弹

时间:2017-05-06 14:06:23

标签: android android-textureview

iam使用textureView绘制json数据,比如波形,它的绘制完美,但我想更新绘图的背景onTouchACTION_MOVE但是我面对并且问题它使我的绘图轻弹这个gif图像当然,用手指移动视图时的问题

enter image description here

这个代码更新了背景颜色

  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;

任何人都知道这里发生了什么以及如何解决它

0 个答案:

没有答案