TextPaint textPaint =new TextPaint();
textPaint.setTextSize(40);
//是否使用伪粗体 之所以叫伪粗体( fake bold ),因为它并不是通过选用更高 weight 的字体让文字变粗,而是通过程序在运行时把文字给「描粗」了。
textPaint.setFakeBoldText(true);
//是否加下划线
textPaint.setUnderlineText(true);
//是否加删除线
textPaint.setStrikeThruText(true);
String text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
StaticLayout staticLayout = new StaticLayout(text,textPaint,600, Layout.Alignment.ALIGN_NORMAL,
1,0,true);
String text2 = "a\nbc\ndefghi\njklm\nnopqrst\nuvwx\nyz";
StaticLayout staticLayout2 = new StaticLayout(text2, textPaint, 600,
Layout.Alignment.ALIGN_NORMAL, 1, 0, true);
canvas.save();
canvas.translate(50,100);
staticLayout.draw(canvas);
canvas.translate(0,200);
staticLayout2.draw(canvas);
canvas.restore();