Android-Talkback在内容描述的末尾宣布类类型。 [英] Android - Talkback announces class type at end of content description.

查看:291
本文介绍了Android-Talkback在内容描述的末尾宣布类类型。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于多个类类型,这在很多地方都发生过,但现在我将坚持一个按钮示例。

This is happening in several places for multiple class types but I'll stick with a button example for now.

所以我有一个按钮,我希望对讲功能宣布为播放。内容描述设置为播放。但是,对讲功能也宣布了该课程,因此其显示为播放按钮。

So I have a button which I want talkback to announce as "Play". The content description is set to "Play". However, talkback is also announcing the class too, so it reads as "Play Button".

我尝试通过重载onInitializeAccessibilityNodeInfo方法来尝试在其他地方找到的解决方案

I tried a solution I found elsewhere by overloading the onInitializeAccessibilityNodeInfo method

private void setupContentDescriptors() {
    mPlayPauseButton.setAccessibilityDelegate(new View.AccessibilityDelegate() {
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info)
        {
            super.onInitializeAccessibilityNodeInfo(host, info);

            //blanked to prevent talkback from announcing class/type
            info.setClassName("");
            info.setContentDescription("Play");
        }
    });
}

将类名设置为效果很好,但是我很快发现了这一点解决方案仅适用于API 23及更高版本。
根据文档,从API 23开始,委托方法是在宿主方法之后调用的,所有属性都可以在不被宿主类覆盖的情况下进行修改。

Setting the class name to "" worked perfectly, but I soon found out this solution only worked for API 23 and above. According to the docs, "Starting in API 23, delegate methods are called after host methods, which all properties to be modified without being overwritten by the host class."

我尝试了其他几种方法都没有用。
个想法?

I've tried several other methods to no avail. Ideas?

推荐答案

在API 23之前,您需要创建一个子类并实现 onInitializeAccessibilityNodeInfo()如果您需要覆盖类名。

Prior to API 23, you will need to create a subclass and implement onInitializeAccessibilityNodeInfo() if you need to override the class name. You cannot override it by using a delegate.

也就是说,话语提示正试图通过讲角色说明为用户提供一致的高质量体验。在绝大多数情况下,您不应尝试覆盖此行为。

That said, TalkBack is attempting to provide a consistent and high-quality experience for your user by speaking role descriptions. In the vast majority of cases, you should not attempt to override this behavior.

这篇关于Android-Talkback在内容描述的末尾宣布类类型。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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