canvas drawtext with multiline
问题 I am developing a image commenting application. I draw text in canvas with canvas.drawText(text, x, y, imgPaint); This appears in a single line. I need to break the line to multiline when the text crosses the canvas width Thanks in advance 回答1: You need to use StaticLayout : TextPaint mTextPaint=new TextPaint(); StaticLayout mTextLayout = new StaticLayout("my text\nNext line is very long text that does not definitely fit in a single line on an android device. This will show you how!",