Reputation: 9297
I'm trying to draw a line like in the code below, but I get nothing! Have I missed something or what could be wrong? I call this code with drawObjects(canvas);
between canvas = surfaceHolder.lockCanvas();
and surfaceHolder.unlockCanvasAndPost(canvas);
Help is preciated!
// 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);
}
Upvotes: 1
Views: 1436
Reputation: 13855
As stated in my comment, use the correct paint mode:
paint.setStyle(Paint.Style.STROKE);
This will put it in the mode to draw lines.
There is also paint.style.FILL
for filling, and paint.style.FILL_AND_STROKE
.
Upvotes: 1