#compose
Title
# compose
l

Lucas Kivi

12/21/2022, 8:56 PM
Does anyone have any experience adding accessibility “links” to compose annotated strings? When you add clickable segments to a
SpannableString
you get this behavior in XML.
The best I have been able to do so far is adding custom actions!
l

Lucas Kivi

12/22/2022, 12:51 AM
Thanks for the response! 👀
This code yielded no such links, unfortunately
Copy code
val string = buildAnnotatedString {
    append("link: Jetpack Compose")
    // attach a string annotation that stores a URL to the text "Jetpack Compose".
    addStringAnnotation(
        tag = "URL",
        annotation = "<https://developer.android.com/jetpack/compose>",
        start = 6,
        end = 21
    )
}

ClickableText(
    text = string,
) {}
z

Zach Klippenstein (he/him) [MOD]

12/22/2022, 1:01 AM
Yep addStringAnnotation won’t do it, gotta use addUrlAnnotation
l

Lucas Kivi

12/22/2022, 1:01 AM
👀
Very, very nice!!
Thank you so much! I do have a follow up question, what if I wanted to perform intra-app navigation in one of these links 🤔 I currently have it rigged up in a sort of haphazard way.
z

Zach Klippenstein (he/him) [MOD]

12/22/2022, 1:11 AM
Unfortunately it only supports urls right now, so you’d have to do that using a url handler somehow.
l

Lucas Kivi

12/22/2022, 1:17 AM
Ok, thank you for the update. I have something working at the moment via actions. However, I will consider swapping to the url handler to support the accessibility
Links
feature for consistency.
123 Views