启用 TalkBack 后,有没有办法将辅助功能焦点手册设置为特定视图?例如,当我的 Activity 启动时,我希望 TalkBack 自动关注某个 Button(视图周围的黄框)并阅读其内容描述。
到目前为止我已经尝试过:
myButton.setFocusable(true);
myButton.setFocusableInTouchMode(true);
myButton.requestFocus();
requestFocus() 似乎只是请求输入焦点,与可访问性焦点无关。我也试过:
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
myButton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
myButton.announceForAccessibility("accessibility test");
myButton.performAccessibilityAction(64, null); // Equivalent to ACTION_ACCESSIBILITY_FOCUS
AccessibilityManager manager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);
if (manager.isEnabled()) {
AccessibilityEvent e = AccessibilityEvent.obtain();
e.setSource(myButton);
e.setEventType(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
e.setClassName(getClass().getName());
e.setPackageName(getPackageName());
e.getText().add("another accessibility test");
manager.sendAccessibilityEvent(e);
}
这些似乎都不起作用。