Android accessibility talkback to say fragment's title

旧巷老猫 提交于 2019-12-04 11:51:58

问题


Is there a way to get the talkback function in Android accessibility to say something after a fragment transaction? I basically want the talkback to say the name/title of the fragment after switching. These titles are set as the titles of the action bar, can they be accessed there? A user can move their finger on top of the text in the action bar to know what screen they are on, but the user won't know that unless they were familiar with the app already.


回答1:


You can force a WINDOW_STATE_CHANGED event from the decor view to announce the ActionBar title. This will also cause TalkBack to clear accessibility focus, so you should only call it when the app's primary content changes.

getWindow().getDecorView()
        .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);


来源:https://stackoverflow.com/questions/19987542/android-accessibility-talkback-to-say-fragments-title

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!