public static StaticLayout make(
      CharSequence text,
      int start,
      int end,
      TextPaint paint,
      int width,
      Layout.Alignment alignment,
      float spacingMult,
      float spacingAdd,
      boolean includePadding,
      @Nullable TextUtils.TruncateAt ellipsize,
      int ellipsisWidth,
      int maxLines,
      TextDirectionHeuristicCompat textDirection,
      int breakStrategy,
      int hyphenationFrequency,
      int justificationMode,
      @Nullable int[] leftIndents,
      @Nullable int[] rightIndents,
      boolean useLineSpacingFromFallbacks) {

    if (Build.VERSION.SDK_INT >= 23) {
      StaticLayout.Builder builder =
          StaticLayout.Builder.obtain(text, start, end, paint, width)
              .setAlignment(alignment)
              .setLineSpacing(spacingAdd, spacingMult)
              .setIncludePad(includePadding)
              .setEllipsize(ellipsize)
              .setEllipsizedWidth(ellipsisWidth)
              .setMaxLines(maxLines)
              .setTextDirection(StaticLayoutProxy.fromTextDirectionHeuristicCompat(textDirection))
              .setBreakStrategy(breakStrategy)
              .setHyphenationFrequency(hyphenationFrequency)
              .setIndents(leftIndents, rightIndents);

      if (Build.VERSION.SDK_INT >= 26) {
        builder.setJustificationMode(justificationMode);
      }

      if (Build.VERSION.SDK_INT >= 28) {
        builder.setUseLineSpacingFromFallbacks(useLineSpacingFromFallbacks);
      }

      return builder.build();
    }

    StaticLayout layout =
        getStaticLayoutMaybeMaxLines(
            text,
            start,
            end,
            paint,
            width,
            alignment,
            spacingMult,
            spacingAdd,
            includePadding,
            ellipsize,
            ellipsisWidth,
            maxLines,
            textDirection);

    // Returned layout may not have correct line count (either because it is not supported
    // pre-ICS, or because there is a bug in Android pre-Lollipop that causes the text to span
    // over more lines than we asked for). We need to manually check if that happened and
    // re-create Layout with a substring that will fit into required number of lines.
    if (maxLines > 0) {
      while (layout.getLineCount() > maxLines) {
        int newEnd = layout.getLineStart(maxLines);
        if (newEnd >= end) {
          // to break out of a potential infinite loop
          break;
        }

        // newEnd is where the next line starts, not where the previous line ends
        // we need to skip over the whitespace characters to get to the end of the line
        while (newEnd > start) {
          if (Character.isSpace(text.charAt(newEnd - 1))) {
            --newEnd;
          } else {
            break;
          }
        }

        end = newEnd;

        layout =
            getStaticLayoutMaybeMaxLines(
                text,
                start,
                end,
                paint,
                width,
                alignment,
                spacingMult,
                spacingAdd,
                includePadding,
                ellipsize,
                ellipsisWidth,
                maxLines,
                textDirection);

        if (layout.getLineCount() >= maxLines && layout.getEllipsisCount(maxLines - 1) == 0) {
          CharSequence ellipsizedText = text.subSequence(start, end) + SPACE_AND_ELLIPSIS;
          layout =
              getStaticLayoutMaybeMaxLines(
                  ellipsizedText,
                  0,
                  ellipsizedText.length(),
                  paint,
                  width,
                  alignment,
                  spacingMult,
                  spacingAdd,
                  includePadding,
                  ellipsize,
                  ellipsisWidth,
                  maxLines,
                  textDirection);
        }
      }
    }

    while (!fixLayout(layout)) {
      // try again
    }

    return layout;
  }
Creates a StaticLayout will all the required properties.

@param text The text for the layout
@param start The start index
@param end The end index
@param paint The {@link TextPaint} to be used
@param width The width of the layout
@param alignment The {@link Layout.Alignment}
@param spacingMult The line spacing multiplier
@param spacingAdd The line spacing extra
@param includePadding Whether to include font padding
@param ellipsize The ellipsizing behavior specified by {@link TextUtils.TruncateAt}
@param ellipsisWidth The width of the ellipsis
@param maxLines The maximum number of lines for this layout
@param textDirection The text direction
@param breakStrategy The break strategy
@param hyphenationFrequency The hyphenation frequency
@param leftIndents The array of left indent margins in pixels
@param rightIndents The array of left indent margins in pixels
@param useLineSpacingFromFallbacks Whether to use the fallback font's line spacing
@return A {@link StaticLayout}
library/src/main/java/com/facebook/fbui/textlayoutbuilder/StaticLayoutHelper.java