Android中调用Paint的measureText()方法取得字符串显示的宽度值
1
public
static
float
GetTextWidth(String text,
float
Size) { //第一个参数是要计算的字符串,第二个参数是字提大小
2
TextPaint FontPaint =
new
TextPaint();
3
FontPaint.setTextSize(Size);
4
return
FontPaint.measureText(text);
5
}