Setting content description for option menu android Talkback
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.