Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Talkback select and focus some Jetpack Composable?

In xml, we can simply set android:importantforaccessibility to achieve such a goal. However, in Jetpack Compose, I don't find any similar approach to do so. Say, if I don't want a Text() composable to be selected and focused when Talkback is on, how should I do?

I tried this way but it won't work, as contentDescription should be NoNull:

modifier = modifier.semantics { contentDescription = null }

So then I tried to remove the initial default semantics of a Text composable:

modifier = modifier.clearAndSetSemantics { }

But this won't work too...

The talkback will still try to focus this Text components and read its content.

I also try to manipulate focusProperties() to skip this Text(), but I failed again.

like image 360
Max Xu Avatar asked Nov 23 '25 15:11

Max Xu


1 Answers

SemanticsPropertyReceiver.invisibleToUser() is deprecated, so you can use:

Modifier.semantics{ hideFromAccessibility() }
like image 64
edivanFinger Avatar answered Nov 25 '25 04:11

edivanFinger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!