ContentDescriptionSpan

class ContentDescriptionSpan(var contentDescription: String?) : CharacterStyle

Extends the CharacterStyle class to include a dedicated field for an accessibility content description. This is useful in cases where the spanned content either cannot be described via the spanned text alone (for example, an image) or when the text of the span could use extra clarification for users of accessibility services like screen readers.

For example, some text that says "Click the button above to continue" may not be descriptive enough for a user without the visual context of which button is above the text. You could use this span to change "button above" to something more descriptive like "next step button" without changing the visual text.

val sb: SpannableStringBuilder = SpannableStringBuilder("Click the button above to continue")
sb.setSpan(ContentDescriptionSpan("next step button"), 10, 22, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

Text.create(c).text(sb).build()

Constructors

Link copied to clipboard
constructor(contentDescription: String?)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open override fun updateDrawState(tp: TextPaint)