繁星点点滴滴
您可以使用getTextBounds(String text, int start, int end, Rect bounds)Paint对象的方法。您可以使用a提供的绘制对象,也可以使用TextView所需的文本外观自行构建。使用Textview,您可以执行以下操作:Rect bounds = new Rect();Paint textPaint = textView.getPaint();textPaint.getTextBounds(text, 0, text.length(), bounds);int height = bounds.height();int width = bounds.width();