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
Best Answer
I found another way using static layouts. The code is here for anyone to refer to: