Skip to content Skip to sidebar Skip to footer

Android - Drawing A Line

I want to draw a line on the screen usign touch listener, but when I try to draw line again, it erases the previous line. I am using the code below. I am unable to find a solution

Solution 1:

u can draw a line using canvas object but u r trying to draw second line using bitmap object try to draw with canvas object

 protected void onDraw(Canvas canvas)

 {
     Paint p = new Paint();
     p.setColor(colordraw);
     p.setColor(Color.BLUE);
     canvas.drawLine(x1, y1, x2 , y2, p);
     canvas.drawLine(x1, y1, x2 , y2, p);
     invalidate();
 }

Post a Comment for "Android - Drawing A Line"