title: How to quickly get width and height of TextView using Paint.getTextBounds()?
body: <p>There is a method in Paint class: <a href="http://developer.android.com/reference/android/graphics/Paint.html#getTextBounds%28java.lang.String,%20int,%20int,%20android.graphics.Rect%29" rel="nofollow noreferrer">Paint.getTextBounds()</a> which returns <code>Rect</code> occupied by some text. But according to <a href="https://stackoverflow.com/a/7579469/1048087">this</a> answer it returns something different then width/height of TextView.</p>
  
  <p><strong>Q1: Is there a way to get width and height of TextView using <code>Rect</code> returned by <a href="http://developer.android.com/reference/android/graphics/Paint.html#getTextBounds%28java.lang.String,%20int,%20int,%20android.graphics.Rect%29" rel="nofollow noreferrer">Paint.getTextBounds()</a>?</strong></p>
  
  <p>Note, I do need to know width/height precisely. I will be happy to know upper bound of the <code>rect</code> with possible error about 2-3%, but it MUST be not greater (and should work for any phone not depending on screen resolution and pixel density) then TextView bounds</p>
  
  <p><strong>Q2: Is there any other QUICK method of determining width and height of some text with specified textSize?</strong></p>
  
  <p>I know, width can be determined by <a href="http://developer.android.com/reference/android/graphics/Paint.html#measureText%28java.lang.String%29" rel="nofollow noreferrer">Paint.measureText()</a>, but this doesn't return height. Height can be determined by creating new <code>StaticLayout</code> with text and then calling <a href="http://developer.android.com/reference/android/text/Layout.html#getHeight%28%29" rel="nofollow noreferrer">StaticLayout.getHeight()</a>, but this is too slow. I need something more quicker.</p>
  
  <hr>
  
  <p>The background for all of this is making <code>AutoFitTextView</code> which will automaticaly fit text inside its bounds by up- or down-scaling text size, and it should do this quickly, as there will be many of such <code>AutoFitTextView</code>s changed dynamically very quickly.</p>