我需要知道给定字体句柄的文本字符串的宽度(或字体名称+字体大小+字体样式数据)。
Windows中的我过去常常使用GetTextExtentPoint()
答案 0 :(得分:9)
使用此代码
Rect bounds = new Rect();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text, 0, text.length(), bounds);
int height = bounds.height();
int width = bounds.width();
答案 1 :(得分:0)
你可以获得TextView的TypeFace:http://developer.android.com/reference/android/widget/TextView.html#getTypeface() 但是很难获得字体系列,请查看: Check the family of a Typeface object in Android