Looks like there is a measureText
method available on Paint
. I also found an example:
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStrokeWidth(5);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setTextSize(64);
mPaint.setTypeface(Typeface.create(Typeface.SERIF, Typeface.ITALIC));
// ...
float w = mPaint.measureText(text, 0, text.length());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…