如果我快速移动手指,我需要用手指画一条带有锋利边缘的线条,但是当移动速度慢时,线条变形如下所示。看起来我应该移动一个矩形。
到目前为止,这是我的代码:
public boolean onTouchEvent(MotionEvent event) {
touchX = event.getX();
touchY = event.getY();
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
drawPath.moveTo(touchX, touchY);
startX = touchX;
startY = touchY;
somethingWasDrawn = false;
break;
case MotionEvent.ACTION_MOVE:
drawPath.lineTo(touchX, touchY);
break;
case MotionEvent.ACTION_UP:
drawCanvas.drawPath(drawPath, drawPaint);
drawPath.reset();
break;
drawPaint像这样初始化:
Paint drawPaint = new Paint();
drawPaint.setColor(paintColor);
drawPaint.setAntiAlias(false);
drawPaint.setStrokeWidth(strokeWith);
drawPaint.setStyle(Paint.Style.STROKE);
drawPaint.setStrokeJoin(Paint.Join.MITER);
drawPaint.setStrokeCap(Paint.Cap.BUTT);
你有什么提示吗?