code: private Rect calcBounds(int index, Paint paint) {
          //Calculate the text bounds
          Rect bounds = new Rect();
          CharSequence title = getTitle(index);
          bounds.right = (int) paint.measureText(title, 0, title.length());
          bounds.bottom = (int) (paint.descent() - paint.ascent());
          return bounds;
      }
docs: Calculate the bounds for a view's title
  
  @param index
  @param paint
  @return