public static int getHeight(@Nullable Layout layout) {
    if (layout == null) {
      return 0;
    }

    int extra = 0;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH
        && layout instanceof StaticLayout) {
      int line = Math.max(0, layout.getLineCount() - 1);
      int above = layout.getLineAscent(line);
      int below = layout.getLineDescent(line);
      float originalSize = (below - above - layout.getSpacingAdd()) / layout.getSpacingMultiplier();
      float ex = below - above - originalSize;
      if (ex >= 0) {
        extra = (int) (ex + 0.5);
      } else {
        extra = -(int) (-ex + 0.5);
      }
    }
    return layout.getHeight() - extra;
  }
Prior to version 20, If the Layout specifies extra space between lines (either by spacingmult
or spacingadd) the StaticLayout would erroneously add this space after the last line as well.
This bug was fixed in version 20. This method calculates the extra space and reduces the height
by that amount.

@param layout The layout.
@return The height of the layout.
library/src/main/java/com/facebook/fbui/textlayoutbuilder/util/LayoutMeasureUtil.java