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();