Android:如何在扩展 SeekBar 时从 AccessibilityEvents 中消除语音文本? [英] Android: How to eliminate spoken text from AccessibilityEvents when extending SeekBar?

查看:28
本文介绍了Android:如何在扩展 SeekBar 时从 AccessibilityEvents 中消除语音文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android 应用程序包含一个基于 SeekBar 的自定义滑块控件,我想在我的控件中附加一个自定义文本短语以解释其对辅助功能的用途.

My Android app contains a custom slider control based on the SeekBar, and I want to attach a custom text phrase to my control to explain its use for Accessibility.

我已经使用 View.setContentDescription(text) 成功地完成了这项工作,当我从 Activity.onCreate 请求将焦点放在我的滑块控件上时,TalkBack 会正确说出这句话.

I have done this successfully using View.setContentDescription(text), and TalkBack correctly speaks the phrase when I request focus on my slider control from Activity.onCreate.

到目前为止,一切都很好.但是,当我触摸控件时,我相信它在我的 Android API 16 测试设备上设置了 AccessibilityFocus,额外的词被添加到口语短语中,即...寻求控制".0%'.我想删除这些额外的字词.

So far, so good. However, when I touch the control, which I believe sets the AccessibilityFocus on my Android API 16 test device, extra words are being added to the spoken phrase, i.e. '...seek control. 0 per cent'. I want to remove these additional words.

我试图在 View.onInitializeAccessibilityEvent(event) 中使用 event.getText().clear() 消除它们,但没有成功.将事件回显到 LogCat 会报告 event.contentDescription 中的正确短语,而 event.text 中没有条目,但额外的词出现在设备硬件的音频输出和在 Menu->Settings->Accessibility->TalkBack->Settings->Developer Settings->Display Speech Output 显示的屏幕调试文本中.

I have tried to eliminate them using event.getText().clear() in View.onInitializeAccessibilityEvent(event) without success. Echoing the event to LogCat reports the correct phrase in event.contentDescription and no entries in event.text, but the extra words appear both in the audio output from the device hardware and in the on-screen debug text displayed by Menu->Settings->Accessibility->TalkBack->Settings->Developer Settings->Display Speech Output.

请谁能建议添加额外单词的位置,以及如何消除它们?

Please can anyone suggest where the extra words are being added, and how to eliminate them?

欢迎提出任何建设性的建议.谢谢.

Any constructive suggestions would be welcomed. Thanks.

更新

我可以看到我的自定义控件上的某些通过触摸探索(初始单击)事件没有通过它的 onInitializeAccessibilityEventdispatchPopulateAccessibilityEvent 方法,因为我是故意的调用 event.setContentDescription(null).尽管如此,我的自定义控件的 ContentDescription 生成了一个 AccessibilityEvent,在代码的 Activity.onCreate 中设置,加上额外的词 I'我正在努力消除.

I can see that some Explore By Touch (initial single-tap) event on my custom control does not pass through either its onInitializeAccessibilityEvent or dispatchPopulateAccessibilityEvent methods as I am deliberately calling event.setContentDescription(null). Despite this, there is an AccessibilityEvent being generated with my custom control's ContentDescription, set in Activity.onCreate in code, plus the extra words I'm trying to eliminate.

我还在自定义控件的父级 ViewGroup 上设置了一个 AccessibilityDelegate 以提供其 onRequestSendAccessibilityEvent 调用的可见性.这确认没有包含我的 ContentDescription 的事件通过.

I've also set an AccessibilityDelegate on my custom control's parent ViewGroup to give visibility of its onRequestSendAccessibilityEvent calls. This confirms that no event containing my ContentDescription is passing through.

这非常令人费解,并且在使用 API 16 的模拟器和真实硬件上都会发生.有什么想法吗?

This is very puzzling, and happens on both the emulator and real hardware with API 16. Any ideas?

推荐答案

我认为这是 TalkBack 中的一个错误,并提出了 Google Eyes-Free 问题 #375,包括示例代码.

I believe that this is a bug in TalkBack, and have raised Google Eyes-Free issue #375, including example code.

更新:Google 现已将其存档.链接移至:http://code.google.com/archive/p/eyes-free/issues/375

Update: Google have now archived this. Link moved to: http://code.google.com/archive/p/eyes-free/issues/375

这篇关于Android:如何在扩展 SeekBar 时从 AccessibilityEvents 中消除语音文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆