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. |
BidiFormatter.Builder |
A class for building a BidiFormatter with non-default options. |
HtmlCompat |
Backwards compatible version of |
ICUCompat |
|
PrecomputedTextCompat |
A text which has the character metrics data. |
PrecomputedTextCompat.Params |
The information required for building |
PrecomputedTextCompat.Params.Builder |
A builder for creating |
TextDirectionHeuristicsCompat |
Some objects that implement TextDirectionHeuristic. |
TextUtilsCompat |
Backwards compatible version of |
Top-level functions summary
inline SpannedString |
buildSpannedString(builderAction: SpannableStringBuilder.() -> Unit)Builds new string by populating a newly created |
Extension functions summary
inline SpannableStringBuilder |
SpannableStringBuilder.backgroundColor(Wrap appended text in |
inline SpannableStringBuilder |
SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline Unit |
Clear all spans from this text. |
inline SpannableStringBuilder |
SpannableStringBuilder.color(Wrap appended text in |
inline Array<T> |
Get all spans that are instance of |
inline String |
Html-encode the string. |
inline SpannableStringBuilder |
SpannableStringBuilder.inSpans(span: Any, builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline SpannableStringBuilder |
SpannableStringBuilder.inSpans(Wrap appended text in |
inline Boolean |
Returns whether the given |
inline SpannableStringBuilder |
SpannableStringBuilder.italic(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline Spanned |
String.parseAsHtml(Returns a |
inline SpannableStringBuilder |
SpannableStringBuilder.scale(Wrap appended text in |
inline operator Unit |
|
inline operator Unit |
|
inline SpannableStringBuilder |
SpannableStringBuilder.strikeThrough(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline SpannableStringBuilder |
SpannableStringBuilder.subscript(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline SpannableStringBuilder |
SpannableStringBuilder.superscript(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
inline String |
Returns a string of HTML from the spans in this |
inline Spannable |
Returns a new |
inline Spanned |
Returns a new |
inline Int |
Returns the length that the specified |
inline SpannableStringBuilder |
SpannableStringBuilder.underline(builderAction: SpannableStringBuilder.() -> Unit)Wrap appended text in |
Extension properties summary
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(
color: @ColorInt Int,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder
Wrap appended text in builderAction in a BackgroundColorSpan.
| See also | |
|---|---|
inSpans |
bold
inline fun SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in a bold StyleSpan.
| See also | |
|---|---|
inSpans |
color
inline fun SpannableStringBuilder.color(
color: @ColorInt Int,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder
Wrap appended text in builderAction in a ForegroundColorSpan.
| See also | |
|---|---|
inSpans |
getSpans
inline fun <T : Any> Spanned.getSpans(start: Int = 0, end: Int = length): Array<T>
Get all spans that are instance of T.
inSpans
inline fun SpannableStringBuilder.inSpans(span: Any, builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
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.
inSpans
inline fun SpannableStringBuilder.inSpans(
vararg spans: Any,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder
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.
isDigitsOnly
inline fun CharSequence.isDigitsOnly(): Boolean
Returns whether the given CharSequence contains only digits.
| See also | |
|---|---|
isDigitsOnly |
italic
inline fun SpannableStringBuilder.italic(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in an italic StyleSpan.
| See also | |
|---|---|
inSpans |
parseAsHtml
inline fun String.parseAsHtml(
flags: Int = FROM_HTML_MODE_LEGACY,
imageGetter: Html.ImageGetter? = null,
tagHandler: Html.TagHandler? = null
): Spanned
Returns a Spanned from parsing this string as HTML.
| Parameters | |
|---|---|
flags: Int = FROM_HTML_MODE_LEGACY |
Additional option to set the behavior of the HTML parsing. Default is set to |
imageGetter: Html.ImageGetter? = null |
Returns displayable styled text from the provided HTML string. |
tagHandler: Html.TagHandler? = null |
Notified when HTML tags are encountered a tag the parser does not know how to interpret. |
| See also | |
|---|---|
fromHtml |
scale
inline fun SpannableStringBuilder.scale(
proportion: Float,
builderAction: SpannableStringBuilder.() -> Unit
): SpannableStringBuilder
Wrap appended text in builderAction in a RelativeSizeSpan.
| See also | |
|---|---|
inSpans |
set
inline operator fun Spannable.set(range: IntRange, span: Any): Unit
Add span to the range of the text.
val s = "Hello, World!".toSpannable()
s[0..5] = UnderlineSpan()
Note: The range end value is exclusive.
| See also | |
|---|---|
setSpan |
set
inline operator fun Spannable.set(start: Int, end: Int, span: Any): Unit
Add span to the range start…end of the text.
val s = "Hello, World!".toSpannable()
s[0, 5] = UnderlineSpan()
Note: The end value is exclusive.
| See also | |
|---|---|
setSpan |
strikeThrough
inline fun SpannableStringBuilder.strikeThrough(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in a StrikethroughSpan.
| See also | |
|---|---|
inSpans |
subscript
inline fun SpannableStringBuilder.subscript(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in a SubscriptSpan.
| See also | |
|---|---|
inSpans |
superscript
inline fun SpannableStringBuilder.superscript(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in a SuperscriptSpan.
| See also | |
|---|---|
inSpans |
toHtml
inline fun Spanned.toHtml(option: Int = TO_HTML_PARAGRAPH_LINES_CONSECUTIVE): String
Returns a string of HTML from the spans in this Spanned.
| See also | |
|---|---|
toHtml |
toSpannable
inline fun CharSequence.toSpannable(): Spannable
Returns a new Spannable from CharSequence, or the source itself if it is already an instance of SpannableString.
toSpanned
inline fun CharSequence.toSpanned(): Spanned
Returns a new Spanned from CharSequence, or the source itself if it is already an instance of SpannedString.
trimmedLength
inline fun CharSequence.trimmedLength(): 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.
| See also | |
|---|---|
getTrimmedLength |
underline
inline fun SpannableStringBuilder.underline(builderAction: SpannableStringBuilder.() -> Unit): SpannableStringBuilder
Wrap appended text in builderAction in an UnderlineSpan.
| See also | |
|---|---|
inSpans |
Extension properties
layoutDirection
val Locale.layoutDirection: Int
Returns layout direction for a given locale.
| See also | |
|---|---|
getLayoutDirectionFromLocale |