A hopefully quick question, but I can’t seem to find any examples… I’d like to write multi-line text to a custom View via a Canvas, and in onDraw() I have:
...
String text = "This is\nmulti-line\ntext";
canvas.drawText(text, 100, 100, mTextPaint);
...
I was hoping this would result in line breaks, but instead I am seeing cryptic characters where the \n would be.
Any pointers appreciated.
Paul
Unfortunately Android doesn’t know what
\nis. What you have to do is strip the\nand then offset the Y to get your text on the next line. So something like this: