Rect rect = new Rect(); //返回包围整个字符串的最小的一个Rect区域 mPaint.getTextBounds(hello, 0, hello.length(), rect); int width = rect.width();// 计算字符串在屏幕中占的宽度 int height = rect.height();// 计算字符串在屏幕中占的高度