user1746619
user1746619

Reputation: 83

draw line between two cordinates in ondraw() in android

I have two points , lets say (x1,y1) and (x2,y2). Now i have to draw a line between these points using OnDraw() method.

I tried as

Paint mPaint = new Paint()     
mPaint.setColor(Color.BLACK);    
path.moveTo(x1, y1);    
path.lineTo(x2, y2);

canvas.drawPath(path, mPaint);

But its not working

Regards,

Sudheer

Upvotes: 0

Views: 4136

Answers (1)

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

Try like this

canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint);

Upvotes: 5

Related Questions