You can use the getTextBounds(String text, int start, int end, Rect bounds)
method of a Paint object. You can either use the paint object supplied by a TextView
or build one yourself with your desired text appearance.
Using a Textview you Can do the following:
Rect bounds = new Rect();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text, 0, text.length(), bounds);
int height = bounds.height();
int width = bounds.width();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…