4

I need to know width of text string given font handle (or font name + font size + font style data).

in Windows I used to use GetTextExtentPoint()

exebook
  • 29,722
  • 29
  • 120
  • 210

2 Answers2

9

use this code

 Rect bounds = new Rect(); 
 Paint textPaint = textView.getPaint();
 textPaint.getTextBounds(text, 0, text.length(), bounds); 
 int height = bounds.height(); 
 int width = bounds.width();
Shailendra Singh Rajawat
  • 8,032
  • 3
  • 32
  • 39
0

You can get TypeFace of TextView: http://developer.android.com/reference/android/widget/TextView.html#getTypeface() but it's hard to get font family, check also this: Check the family of a Typeface object in Android

Community
  • 1
  • 1
maszter
  • 3,601
  • 6
  • 35
  • 51