title: Measuring String Size in Xamarin Forms (Android)
body: <p>In my application, I have a button with a fixed with (currently, 100). Given a string value, I am attempting to set the font size of this button so that the entire string fits on one line.</p>
  
  <p>I have created a custom button along with a renderer for this button. I have the following code in the <code>OnSizeChanged</code> method of the renderer.</p>
  
  <pre><code>var textView = new TextView(Context);
  
  textView.TextSize = 10.0f;
  
  var bounds = new Rect();
  
  textView.Paint.GetTextBounds(text, 0, text.Length, bounds);
  
  var size = bounds.Width() / Resources.DisplayMetrics.ScaledDensity;
  </code></pre>
  
  <p>From some trial and error work, I know that the string will barely fit within the button if I set the font size of the button to be 10.0. However, the code above reports that the size (width) of the string for a font size of 10.0 is about 70.85 (for my device). This doesn't seem to compute as it is much less than what I expected (I would have expected it to be somewhere around 95.0).</p>
  
  <p>What am I missing / doing wrong?</p>