1

我试图在下面的代码中画一条线,但我什么也没得到!我错过了什么或可能出了什么问题吗?drawObjects(canvas);我用betweencanvas = surfaceHolder.lockCanvas();surfaceHolder.unlockCanvasAndPost(canvas);Help 来调用这段代码!

    // Method to draw objects
private void drawObjects(Canvas canvas) {

    // Clear screen with black color
    canvas.drawRGB(0, 0, 0);

    // Draw line
    if(fingerUp) {
        Log.i("Test", "Draw line now!");
        path.moveTo(xStart, yStart);
        path.lineTo(xEnd, yEnd);
        paint.setColor(Color.WHITE);
        paint.setStrokeWidth(10);
        canvas.drawPath(path, paint);
    }

    // Call method draw() in CircleManager to draw all circles in list
    circleManager.drawCirclesInList(canvas);
}
4

1 回答 1

1

正如我的评论中所述,使用正确的绘画模式:

paint.setStyle(Paint.Style.STROKE);

这将使其处于绘制线条的模式。

还有paint.style.FILL用于填充的,和paint.style.FILL_AND_STROKE

于 2013-04-28T08:56:18.597 回答