https://kotlinlang.org logo
#compose
Title
# compose
c

Colton Idle

01/23/2021, 5:53 AM
Can we add a "content description" to an image in compose?
c

Carson Holzheimer

01/23/2021, 6:15 AM
Pretty sure that's handled in semantics modifier?
If you're wanting it for accessibility or testing https://developer.android.com/jetpack/compose/testing. Im not sure if tooltips exist if that's what you want
c

Colton Idle

01/23/2021, 6:57 AM
I just have an image and want to make sure if someone uses an a11y reader like talkback that they can hear my description of the image. This will not be used for testing. I took a look at the Modifier.semantics but couldn't figure out any way to set a content description. There was an accessibilityLabel but it's deprecated.
c

Carson Holzheimer

01/23/2021, 7:03 AM
Seems like that's what you want. Not sure what the replacement is if that's deprecated though https://bryanherbst.com/2020/11/03/compose-semantics-talkback/
👍 1
c

Colton Idle

01/23/2021, 7:06 AM
Thanks @Carson Holzheimer I'll keep trying it!
a

Andrew Neal

01/23/2021, 3:06 PM
accessibilityLabel
was replaced with
contentDescription
. Both
Icon
and
Image
will have a parameter for it either in the next release or the one after. It was merged earlier this week. But still using
Modifier.semantics
under the hood. https://android-review.googlesource.com/c/platform/frameworks/support/+/1545989
👍 1
c

Colton Idle

01/23/2021, 8:48 PM
Thank you! The param for it will be helpful instead of wrapping it with modifier semantics.
15 Views