[英]ApiDemo's: Android Accessibility Node Provider is this working with talkback?
I was exploring the API Demos provided in android sdk, android version > 4.1 . 我正在探索android sdk中提供的API演示,android版本> 4.1。 API Demos -> Accessibility -> Accessibility Node Provider
API演示 - >辅助功能 - >辅助功能节点提供程序
The AccessibilityNodeProvider contains some custom views with Red, Green, Blue colors. AccessibilityNodeProvider包含一些具有红色,绿色,蓝色的自定义视图。 As mentioned in the activity , i enabled the talkback and i tried to hover on the views.
正如活动中提到的,我启用了对讲,我试图将鼠标悬停在视图上。 Talkback couldn't read the colors.
对讲无法读取颜色。 Talkback is reading the text available in the activity but not the colors.
对讲正在阅读活动中可用的文本,而不是颜色。 I was wondering does Talkback reads the colors (custom views) in the activity ?
我想知道Talkback是否读取了活动中的颜色(自定义视图)?
Thanks in advance 提前致谢
In the package com.example.android.apis.accessibility in the AccessibilityNodeProviderActivity class, find the sendAccessibilityEventForVirtualView() method. 在AccessibilityNodeProviderActivity类的com.example.android.apis.accessibility包中,找到sendAccessibilityEventForVirtualView()方法。 You need to set the eventType on the AccessibilityEvent to AccessibilityEvent.TYPE_ANNOUNCEMENT like so:
您需要将AccessibilityEvent上的eventType设置为AccessibilityEvent.TYPE_ANNOUNCEMENT,如下所示:
event.getText().add(virtualView.mText);
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);
That should make it announce the text. 这应该让它宣布文本。 But it still doesn't highlight the view -- don't know if the expected behaviour is that the node should be highlighted.
但它仍然没有突出显示视图 - 不知道预期的行为是否应该突出显示该节点。
I've found this Google Code example to be a better example of speaking text in a node provider setup. 我发现此Google代码示例是在节点提供程序设置中说出文本的更好示例。
(Old answer below.) (旧答案如下。)
In the AccessibilityNodeProviderActivity
class, look at the method sendAccessibilityEventForVirtualView()
.在 AccessibilityNodeProviderActivity
类中,查看方法sendAccessibilityEventForVirtualView()
。You'll see that the text set into the event is the text defined in accessibility_node_provider.xml
.您将看到设置到事件中的文本是 accessibility_node_provider.xml
定义的文本。You would replace that text with a wording of the different color values to get what you asked for. 您可以使用不同颜色值的措辞替换该文本,以获得您要求的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.