Search code examples
androidcanvasdrawable

how to remove text drawn from Canvas in android


I want to remove text from Canvas that I have drawn by using following code.

   canvas.drawText(label, width / 4, height / 3, paint_text);

Once it is done, user can edit that text so I want to delete the already drawn text from canvas before edit it and write new text.

One thing I want to make clear that I write text on canvas with image bitmap.

Is it possible in any other way? Please help me solve this.


Solution

  • There is only way to remove text from canvas is to take one condition and if condition did not satisfied then do not draw these text. Generally we use canvas to draw continue-sly.

    if(flag){
    ///draw text
    }else{
    //Do not draw
    }
    

    to call onDraw() method again to show new changes call inValidate() if you are in same thread or postInvalidate() from different thread