ContentDescriptionSpan

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.


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

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

Constructors

Link copied to clipboard
constructor(@Nullable contentDescription: String)

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun setContentDescription(contentDescription: String)
Link copied to clipboard
Link copied to clipboard