用android的canvas drawText的时候,即使text包行\r\n,画出来的仍然不会换行。
这时需要用到TextPaint
TextPaint textPaint = new TextPaint();
textPaint.setARGB(0xFF, 0, 0, 0);
textPaint.setTextSize(20.0F);
textPaint.setAntiAlias(true);
StaticLayout layout = new StaticLayout("abc\r\n123", textPaint, 300,
Alignment.ALIGN_NORMAL, 1.0F, 0.0F, true);
cv.save();
cv.translate(20, 20);//从20,20开始画
layout.draw(cv);
cv.restore();//别忘了restore