Google is committed to advancing racial equity for Black communities. See how.

androidx.core.text

Interfaces

TextDirectionHeuristicCompat

Interface for objects that use a heuristic for guessing at the paragraph direction by examining text.

Classes

BidiFormatter

Utility class for formatting text for display in a potentially opposite-directionality context without garbling.

HtmlCompat

Backwards compatible version of Html.

ICUCompat

PrecomputedTextCompat

A text which has the character metrics data.

TextDirectionHeuristicsCompat

Some objects that implement TextDirectionHeuristic.

TextUtilsCompat

Backwards compatible version of TextUtils.

Top-level functions summary

SpannedString

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

Extension functions summary

For android.text.Spannable
Unit

Clear all spans from this text.

operator Unit
Spannable.set(start: Int, end: Int, span: Any)

Add span to the range start…end of the text.

operator Unit
Spannable.set(range: IntRange, span: Any)

Add span to the range of the text.

For android.text.SpannableStringBuilder
SpannableStringBuilder
SpannableStringBuilder.backgroundColor(@ColorInt color: Int, builderAction: SpannableStringBuilder.() -> Unit)

Wrap appended text in builderAction in a BackgroundColorSpan.

SpannableStringBuilder

Wrap appended text in builderAction in a bold StyleSpan.

SpannableStringBuilder
SpannableStringBuilder.color(@ColorInt color: Int, builderAction: SpannableStringBuilder.() -> Unit)

Wrap appended text in builderAction in a ForegroundColorSpan.

SpannableStringBuilder
SpannableStringBuilder.inSpans(vararg spans: Any, builderAction: SpannableStringBuilder.() -> Unit)

Wrap appended text in builderAction in spans.

SpannableStringBuilder

Wrap appended text in builderAction in span.

SpannableStringBuilder

Wrap appended text in builderAction in an italic StyleSpan.

SpannableStringBuilder
SpannableStringBuilder.scale(proportion: Float, builderAction: SpannableStringBuilder.() -> Unit)

Wrap appended text in builderAction in a RelativeSizeSpan.

SpannableStringBuilder

Wrap appended text in builderAction in a StrikethroughSpan.

SpannableStringBuilder

Wrap appended text in builderAction in a SubscriptSpan.

SpannableStringBuilder

Wrap appended text in builderAction in a SuperscriptSpan.

SpannableStringBuilder

Wrap appended text in builderAction in an UnderlineSpan.

For android.text.Spanned
Array<out T>
Spanned.getSpans(start: Int = 0, end: Int = length)

Get all spans that are instance of T.

String
Spanned.toHtml(option: Int = TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)

Returns a string of HTML from the spans in this Spanned.

For kotlin.CharSequence
Boolean

Returns whether the given CharSequence contains only digits.

Spannable

Returns a new Spannable from CharSequence, or the source itself if it is already an instance of SpannableString.

Spanned

Returns a new Spanned from CharSequence, or the source itself if it is already an instance of SpannedString.

Int

Returns the length that the specified CharSequence would have if spaces and ASCII control characters were trimmed from the start and end, as by String.trim.

For kotlin.String
String

Html-encode the string.

Spanned
String.parseAsHtml(flags: Int = FROM_HTML_MODE_LEGACY, imageGetter: ImageGetter? = null, tagHandler: TagHandler? = null)

Returns a Spanned from parsing this string as HTML.

Extension properties summary

For java.util.Locale
Int

Returns layout direction for a given locale.

Top-level functions

buildSpannedString

inline fun buildSpannedString(builderAction: SpannableStringBuilder.() -> Unit): SpannedString

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

Extension functions

backgroundColor

inline fun SpannableStringBuilder.backgroundColor(
    @ColorInt color: Int,
    builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder

Wrap appended text in builderAction in a BackgroundColorSpan.

bold

inline fun SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder

Wrap appended text in builderAction in a bold StyleSpan.

clearSpans

inline fun