SpannableStringBuilderKt

Added in 1.1.0

public final class SpannableStringBuilderKt


Summary

Public methods

static final @NonNull SpannableStringBuilder
backgroundColor(
    @NonNull SpannableStringBuilder receiver,
    @ColorInt int color,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a BackgroundColorSpan.

static final @NonNull SpannableStringBuilder
bold(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a bold StyleSpan.

static final @NonNull SpannedString

Builds new string by populating a newly created SpannableStringBuilder using the provided builderAction and then converting it to SpannedString.

static final @NonNull SpannableStringBuilder
color(
    @NonNull SpannableStringBuilder receiver,
    @ColorInt int color,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a ForegroundColorSpan.

static final @NonNull SpannableStringBuilder
inSpans(
    @NonNull SpannableStringBuilder receiver,
    @NonNull Object span,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in span.

static final @NonNull SpannableStringBuilder
inSpans(
    @NonNull SpannableStringBuilder receiver,
    @NonNull Object spans,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in spans.

static final @NonNull SpannableStringBuilder
italic(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in an italic StyleSpan.

static final @NonNull SpannableStringBuilder
scale(
    @NonNull SpannableStringBuilder receiver,
    float proportion,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a RelativeSizeSpan.

static final @NonNull SpannableStringBuilder

Wrap appended text in builderAction in a StrikethroughSpan.

static final @NonNull SpannableStringBuilder
subscript(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a SubscriptSpan.

static final @NonNull SpannableStringBuilder

Wrap appended text in builderAction in a SuperscriptSpan.

static final @NonNull SpannableStringBuilder
underline(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in an UnderlineSpan.

Public methods

backgroundColor

public static final @NonNull SpannableStringBuilder backgroundColor(
    @NonNull SpannableStringBuilder receiver,
    @ColorInt int color,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a BackgroundColorSpan.

See also
inSpans

bold

public static final @NonNull SpannableStringBuilder bold(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a bold StyleSpan.

See also
inSpans

buildSpannedString

public static final @NonNull SpannedString buildSpannedString(
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Builds new string by populating a newly created SpannableStringBuilder using the provided builderAction and then converting it to SpannedString.

color

public static final @NonNull SpannableStringBuilder color(
    @NonNull SpannableStringBuilder receiver,
    @ColorInt int color,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a ForegroundColorSpan.

See also
inSpans

inSpans

public static final @NonNull SpannableStringBuilder inSpans(
    @NonNull SpannableStringBuilder receiver,
    @NonNull Object span,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in span.

Note: the span will only have the correct position if the builderAction only appends or replaces text. Inserting, deleting, or clearing the text will cause the span to be placed at an incorrect position.

public static final @NonNull SpannableStringBuilder inSpans(
    @NonNull SpannableStringBuilder receiver,
    @NonNull Object spans,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in spans.

Note: the spans will only have the correct position if the builderAction only appends or replaces text. Inserting, deleting, or clearing the text will cause the span to be placed at an incorrect position.

italic

public static final @NonNull SpannableStringBuilder italic(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in an italic StyleSpan.

See also
inSpans

scale

public static final @NonNull SpannableStringBuilder scale(
    @NonNull SpannableStringBuilder receiver,
    float proportion,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a RelativeSizeSpan.

See also
inSpans

strikeThrough

public static final @NonNull SpannableStringBuilder strikeThrough(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a StrikethroughSpan.

See also
inSpans

subscript

public static final @NonNull SpannableStringBuilder subscript(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a SubscriptSpan.

See also
inSpans

superscript

public static final @NonNull SpannableStringBuilder superscript(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in a SuperscriptSpan.

See also
inSpans

underline

public static final @NonNull SpannableStringBuilder underline(
    @NonNull SpannableStringBuilder receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SpannableStringBuilderUnit> builderAction
)

Wrap appended text in builderAction in an UnderlineSpan.

See also
inSpans