withAnnotation

Function

Common
inline fun <R : Any> Builder.withAnnotation(
    tag: String,
    annotation: String,
    crossinline block: Builder.() -> R,
): R

Pushes an annotation to the AnnotatedString.Builder, executes block and then pops the annotation.

Parameters

tagthe tag used to distinguish annotations
annotationthe string annotation attached on this AnnotatedString
blockfunction to be executed

Returns

result of the block
Common
inline fun <R : Any> Builder.withAnnotation(
    ttsAnnotation: TtsAnnotation,
    crossinline block: Builder.() -> R,
): R

Pushes an TtsAnnotation to the AnnotatedString.Builder, executes block and then pops the annotation.

Parameters

ttsAnnotationan object that stores text to speech metadata that intended for the TTS engine.
blockfunction to be executed

Returns

result of the block
Common

Deprecated Use LinkAnnotation API for links instead

@ExperimentalTextApi
inline fun <R : Any> Builder.withAnnotation(
    urlAnnotation: UrlAnnotation,
    crossinline block: Builder.() -> R,
): R

Pushes an UrlAnnotation to the AnnotatedString.Builder, executes block and then pops the annotation.

Parameters

urlAnnotationA UrlAnnotation object that stores the URL being linked to.
blockfunction to be executed

Returns

result of the block