I want to created a wrapping text ontop of google maps api. I have been able to do this with a lot of code, but have been working on a better way. My latest attempt is to use the StaticLayout class and the text is wrapping, but I do not know how to position it...no matter what I try it is always starting in the top left corner of the screen....
Asked
Active
Viewed 8,519 times
2 Answers
15
try doing a canvas.translate(x,y)
before you call draw(c)
on the layout.

Andro Selva
- 53,910
- 52
- 193
- 240

veelci
- 180
- 1
- 7
8
You can do it as follows
//Save canvas before translating it, otherwise restore will cause crash (Underflow in restore - more restores than saves)
canvas.save()
canvas.translate(xPos, yPos);
statictextlayout.draw(canvas);
//After that to reset the canvas back for everything else
canvas.restore();
To continue drawing normally afterwards... call canvas.restore() after you staticlayout draw and you should be good to continue drawing on you canvas.

Defolter Ricaris
- 129
- 1
- 2
- 11

Stevanicus
- 7,561
- 9
- 49
- 70
-
4canvas.save() needs to be called before calling canvas.restore(). It seems to work like push() / pop() – Kristupas A. Aug 31 '15 at 08:34