Android TextPaint设置文字加粗怎么写
要设置文字加粗,可以使用TextPaint的setTypeface方法来设置字体样式。以下是一个示例代码:
TextPaint textPaint = new TextPaint();
textPaint.setTypeface(Typeface.DEFAULT_BOLD); // 设置加粗字体样式
textPaint.setTextSize(30); // 设置字体大小
textPaint.setColor(Color.BLACK); // 设置字体颜色
canvas.drawText("Hello World", x, y, textPaint); // 在画布上绘制加粗文字
在上面的示例中,我们使用TextPaint的setTypeface方法来设置字体样式为DEFAULT_BOLD,这将使得绘制的文字加粗。然后我们设置了字体大小和颜色,并使用drawText方法在画布上绘制了加粗的文字。
原文地址: http://www.cveoy.top/t/topic/hfEN 著作权归作者所有。请勿转载和采集!