Question

I´ve created a costum view, and on the onDrawMethod i´ve started to draw some things. A few rects,lines, and a text.

  canvas.drawText("Hello",150,150, paint);

Now, I want to change this text, after an OnTouchEvent.

My problem is, that I don´t know, how to remove the old text. At the moment my second text, which is shown after the TouchEvent, is just overlapping my old text. Should I redraw my hole view with the new text?

Was it helpful?

Solution

Typically you would redraw the entire view if a lot of things are going, but in this scenario you can just draw a box with the same color as the background over the old text, then display the new text on top of it.

If you have a background image, though, then it would be easier just to re-create the whole canvas.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top