Join us for ⁠#Android11: The Beta Launch Show on June 3!

AnnotatedString

data class AnnotatedString
kotlin.Any
   ↳ androidx.ui.text.AnnotatedString

The basic data structure of text with multiple styles. To construct an AnnotatedString you can use Builder.

Summary

Nested classes

Builder class for AnnotatedString.

data

The information attached on the text such as a SpanStyle.

Public constructors

<init>(text: String, spanStyles: List<SpanStyleItem> = listOf(), paragraphStyles: List<ParagraphStyleItem> = listOf())

Public methods

List<AnnotatedString.Item<String>>
getStringAnnotations(tag: String, start: Int, end: Int)

Query the string annotations attached on this AnnotatedString.

operator AnnotatedString

Extension functions

From androidx.ui.text
AnnotatedString
AnnotatedString.capitalize(localeList: LocaleList = LocaleList.current)

Create capitalized AnnotatedString

AnnotatedString
AnnotatedString.decapitalize(localeList: LocaleList = LocaleList.current)

Create capitalized AnnotatedString

AnnotatedString

Return a substring for the AnnotatedString and include the styles in the range of start (inclusive) and end (exclusive).

AnnotatedString
AnnotatedString.toLowerCase(localeList: LocaleList = LocaleList.current)

Create lower case transformed AnnotatedString

AnnotatedString
AnnotatedString.toUpperCase(localeList: LocaleList = LocaleList.current)

Create upper case transformed AnnotatedString

Properties

List<ParagraphStyleItem>

List<SpanStyleItem>

String

Extension properties

From androidx.ui.text
Int

Returns the length of the AnnotatedString.

Public constructors

<init>

AnnotatedString(
    text: String,
    spanStyles: List<SpanStyleItem> = listOf(),
    paragraphStyles: List<ParagraphStyleItem> = listOf())

Public methods

getStringAnnotations

fun getStringAnnotations(
    tag: String,
    start: Int,
    end: Int
): List<AnnotatedString.Item<String>>

Query the string annotations attached on this AnnotatedString. Annotations are metadata attached on the AnnotatedString, for example, a URL is a string metadata attached on the a certain range. Annotations are also store with Item like the styles.

Parameters
tag: String the tag of the annotations that is being queried. It's used to distinguish the annotations for different purposes.
start: Int the start of the query range, inclusive.
end: Int the end of the query range, exclusive.
Return
a list of annotations stored in Item. Notice that All annotations that intersect with the range [start, end) will be returned. When start is bigger than end, an empty list will be returned.

plus

operator fun plus(other: AnnotatedString): AnnotatedString

Properties

paragraphStyles

val paragraphStyles: List<ParagraphStyleItem>

spanStyles

val spanStyles: List<SpanStyleItem>

text

val text: String