3

我想像canvas自由手绘一样在android中绘制涂鸦....

这是我的代码......

                             x = motionEvent.getX();
                 y = motionEvent.getY();
            switch (motionEvent.getAction())
              {
            case MotionEvent.ACTION_DOWN:
                td=1;
                 currentDrawingPath = new DrawingPath();
               currentDrawingPath.paint = currentPaint;
               currentDrawingPath.path = new Path();
                currentDrawingPath.path.moveTo(x, y);
                mX = x;
                mY = y;
            break;
            case MotionEvent.ACTION_MOVE:
                currentDrawingPath.path.lineTo(mX, mY);
                float dx = Math.abs(x - mX);
                float dy = Math.abs(y - mY);
                tm=1;
                isDrawings=true;
                if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) 
                {
            currentDrawingPath.path.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
                mX = x;
                mY = y;
                }
                    break;
            case MotionEvent.ACTION_UP:
                tu=1;
                isDrawings=false;
                currentDrawingPath.path.lineTo(mX, mY);
                drawingSurface.addDrawingPath(currentDrawingPath);
                 undoBtn.setEnabled(true);
                 redoBtn.setEnabled(false);
            break;
            }

涂鸦只会出现在touchs up中,所以请帮我在touchesmove中绘图...

提前致谢

4

0 回答 0