Text("This is a heading")
.padding(16)
.accessibilityAddTraits(.isHeader)
This doesn't show up as a heading in Android TalkBack, because the heading is applied to the .padding() container, which has no content description, and not to the underlying Text.
You can work around this by rewriting to put the accessibility modifier first, e.g. Text("This is a heading").accessibilityAddTraits(.isHeader).padding(16).
I think it might also work to use composeModifier to add semantics(mergeDescendants: true). (Maybe accessibilityAddTraits should do that as a general rule…?)
This doesn't show up as a heading in Android TalkBack, because the heading is applied to the
.padding()container, which has no content description, and not to the underlyingText.You can work around this by rewriting to put the accessibility modifier first, e.g.
Text("This is a heading").accessibilityAddTraits(.isHeader).padding(16).I think it might also work to use
composeModifierto addsemantics(mergeDescendants: true). (MaybeaccessibilityAddTraitsshould do that as a general rule…?)