Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setColor(Color.WHITE);
// Define the string.
String displayText = “Hello World!”;
// Measure the width of the text string.
float textWidth = mTextPaint.measureText(displayText);
测量文字长度
本文介绍了一种使用Paint对象测量文本宽度的方法。通过创建一个带有抗锯齿标志的Paint实例,并设置其颜色为白色,然后定义要显示的字符串,最后利用Paint对象的measureText方法来测量文本的实际宽度。

被折叠的 条评论
为什么被折叠?



