Changing text in BitmapText

We are using BitmapText in our UI, and we are noticing that when our app is run on Android, the BitmapText does not refresh text properly. It seems that when we use setText(“New text”) that if the new text is shorter than the old text, the full BitmapText area is not redrawn - so we see both the new text and the old text underneath.

Does anyone know if there is a way to force BitmapText to redraw its text, properly clearing the draw area? Right now, we are destroying and creating a new BitmapText whenever we want to change the text, which seems slow.

Here’s a picture of the overlapping BitmapText on Android, after changing the text:

Here’s how we are changing the text:

[java] if(textNode == null) {

textNode = new BitmapText(font);





Rectangle textBox = new Rectangle(0, 0, width, height);




I’ve seen this issue talked about before. I can’t remember what/if there was a proper resolution but from what I remember you can work around it by padding your string out to the maximum length you will use with spaces.

(i.e. setX “hello”, setX “hi” becomes setX “hello”, setX "hi ")

That works :slight_smile: Also making sure to use the not-padded string when checking line width. Thanks

1 Like