StaticLayoutBuilderCompat

Class to create StaticLayout using StaticLayout.Builder on API23+ and a hidden StaticLayout constructor before that.

Usage:


StaticLayout staticLayout =
  StaticLayoutBuilderCompat.obtain("Lorem Ipsum", new TextPaint(), 100)
    .setAlignment(Alignment.ALIGN_NORMAL)
    .build();

Types

Link copied to clipboard
Class representing a StaticLayoutBuilder exception from initializing a StaticLayout.

Functions

Link copied to clipboard
Link copied to clipboard
open fun obtain(@NonNull source: CharSequence, @NonNull paint: TextPaint, @IntRange(from = 0) width: Int): StaticLayoutBuilderCompat
Obtain a builder for constructing StaticLayout objects.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setAlignment(@NonNull alignment: Layout.Alignment): StaticLayoutBuilderCompat
Set the alignment.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setEllipsize(@Nullable ellipsize: TextUtils.TruncateAt): StaticLayoutBuilderCompat
Set ellipsizing on the layout.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setEnd(@IntRange(from = 0) end: Int): StaticLayoutBuilderCompat
Set the index + 1 of the end of the text
Link copied to clipboard
@CanIgnoreReturnValue
open fun setHyphenationFrequency(hyphenationFrequency: Int): StaticLayoutBuilderCompat
Set the hyphenation frequency.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setIncludePad(includePad: Boolean): StaticLayoutBuilderCompat
Set whether to include extra space beyond font ascent and descent (which is needed to avoid clipping in some languages, such as Arabic and Kannada).
Link copied to clipboard
Link copied to clipboard
@CanIgnoreReturnValue
open fun setLineSpacing(spacingAdd: Float, lineSpacingMultiplier: Float): StaticLayoutBuilderCompat
Set the line spacing addition and multiplier frequency.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setMaxLines(@IntRange(from = 0) maxLines: Int): StaticLayoutBuilderCompat
Set maximum number of lines.
Link copied to clipboard
@CanIgnoreReturnValue
open fun setStart(@IntRange(from = 0) start: Int): StaticLayoutBuilderCompat
Set the index of the start of the text
Link copied to clipboard
@CanIgnoreReturnValue
open fun setStaticLayoutBuilderConfigurer(@Nullable staticLayoutBuilderConfigurer: StaticLayoutBuilderConfigurer): StaticLayoutBuilderCompat
Set the StaticLayoutBuilderConfigurer which allows additional custom configurations on the static layout.