I am implementing "Read Aloud
" or "Talkback
" for an app. Everything is working with contentDescription
text, but with option menu, I found nothing related to contentDescription
, I want system read "Menu "+ item's name
.
EX: My menu has 2 items: "Create New Folder" and "Delete current folder", currently, when I focus a menu item (Support trackball and bluetooth key), system can talk exactly the menu's text. But I want it talks more like "1: Menu Create New Folder" and "2: Menu Delete current folder".
So, How can I change the read text? How can I get the focused menu item
when bluetooth keyboard press UP/DOWN
key?
The content description attribute links a text description to a control, ImageView, or other focusable object that otherwise has no text content. These objects wouldn't be accessible without some some sort of label or description.
Change the volume for TalkBack It's part of Android's standard volume control. To change the speaking volume: While Talkback speaks, press the volume up or volume down key. If TalkBack isn't speaking, hold one finger on the screen and press the volume up or volume down key.
The TalkBack menu: contains commands that are relevant anywhere on your device. To open the TalkBack menu, swipe down then right, or swipe up then right. Or on devices with multi-finger gestures*, you can also do a three-finger tap.
this answer post AndroidX
androidx.core.view.MenuItemCompat.setContentDescription(menuItem, contentDescription)
It seems they just added the setContentDescription(CharSequence contentDescription)
method to the MenuItem
class on API 26 (Android O)
MenuItemCompat in the v4 support libraries has a
android.support.v4.view.MenuItemCompat.setContentDescription(MenuItem menuItem, CharSequence contentDescription)
method for backwards compatibility on pre-Oreo devices.
For AndroidX see this answer:
https://stackoverflow.com/a/57950952/1236327
As my investigation, in Android internal source code, class ActionMenuItemView.java
method setTitle(CharSequence title)
, the source code also sets setContentDescription(title)
, so Android will read your MenuItem's text as default. I don't know why the core has so inflexible in this case.
Updated:
Thanks for @sofakingforever answer.
Seem Google
just added the setContentDescription(CharSequence contentDescription)
method to the MenuItem
class on API 26 (Android O
).
Updated:
Thanks for new @tim.paetz answer .
Look like all versions are now supported setContentDescription
for menu item using android support v4
libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With