线在画布上不可见

时间:2013-04-28 07:49:33

标签: android android-canvas

我正在尝试在下面的代码中绘制一条线,但我什么都没得到!我错过了什么或者什么可能是错的?我在drawObjects(canvas);canvas = surfaceHolder.lockCanvas(); surfaceHolder.unlockCanvasAndPost(canvas);之间使用 // 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); } 调用此代码!

{{1}}

1 个答案:

答案 0 :(得分:1)

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

paint.setStyle(Paint.Style.STROKE);

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

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