如何防止android对讲说话的seekbar进度 [英] How to prevent android talkback to speak seekbar progress

查看:151
本文介绍了如何防止android对讲说话的seekbar进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义控件,扩展了 SeekBar ,在其中覆盖了 onInitializeAccessibilityNodeInfo ,如下所示:

I have a custom control extending SeekBar, in which I have overridden onInitializeAccessibilityNodeInfo as below:

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName(TextView.class.getName());
}

然后,我将内容描述设置为此控件的我的控件",但是当可访问性成为该控件的焦点时,对讲仍会说我的控件,%x%".我不希望它说出进度,即"x%".与其说我想覆盖对讲文本,不如说"x percent ...",而是宣布我设置的自定义文本,例如选择了x值".怎么做?

Then I set content description as "my control" to this control, but when accessibility focus comes to this control, talkback still speak "my control, %x percent". I don't want it to speak progress i.e. "x percent". Instead of that I want to override the talkback text so that instead of it announcing "x percent..." it announces custom text that I set e.g. "x value selected". How to do it?

推荐答案

我在C#中的Xamarin.Android中做了类似的事情,但是代码应该足够容易移植回Java.另外,请记住,当控件突出显示时,这些更改将覆盖初始对讲.

I did something similar in Xamarin.Android in C#, but the code should be easy enough to port back to Java. Also, keep in mind these changes will override the initial talkback when the control is highlighted.

首先在textView上跟踪值集:

First on the textView that is keeping track of the value set:

textView.AccessibilityLiveRegion = AndroidViews.AccessibilityLiveRegion.Assertive;

然后我必须创建自己的自定义 AccessibilityDelegate :

Then I had to create my own custom AccessibilityDelegate :

public class CustomSeekbarDelegate : Android.Views.View.AccessibilityDelegate
{
    public override void OnInitializeAccessibilityEvent(AndroidViews.View host, AccessibilityEvent e)
    {
        //NOTE: Don't call base to prevent seekbar talkback percentage
    }
}

seekBar.SetAccessibilityDelegate(new CustomSeekbarDelegate());

首次突出显示时,可能有一种方法可以同时保留初始语音控件的可访问性,但是在线上并没有太多内容,这足以满足我们的需求.另外,我没有更多的时间尝试使它正常工作.

There's probably a way to keep both the initial spoken control accessibility when first highlighted, but there's not much online about it and this was good enough for our needs. Plus, I didn't have additional time to try and get that working as well.

这篇关于如何防止android对讲说话的seekbar进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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