Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

word wraped tex on Android canvas

I'm trying to write some strings to a canvas (live wallpaper) however long string don't get word-wraped is there any way to do it?
I think canvas is the only thing I can use for this, since it's a live wallpaper.

like image 762
Luis M Avatar asked Dec 22 '22 21:12

Luis M


1 Answers

No need to do your own word wrapping.

Check out android.text.Layout and its subclasses android.text.StaticLayout and android.text.DynamicLayout

something like this:

StaticLayout layout = new StaticLayout(text, txtpaint, textW,Layout.Alignment.ALIGN_NORMAL, 1.3f, 0, false);
txtcanvas.translate(xoffs, yoffs); //position the text
layout.draw(txtcanvas);
like image 76
Olof Hedman Avatar answered Dec 24 '22 09:12

Olof Hedman