启用触摸浏览时如何保持单指针手势? [英] How can I maintain a one pointer gesture when explore-by-touch is enabled?

查看:27
本文介绍了启用触摸浏览时如何保持单指针手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个捕获用户签名的自定义视图(John Hancock).我希望我们的应用程序尽可能易于访问,因此我特别注意确保针对 TalkBackExplore-by-Touch 优化我们的屏幕.由于Explore-by-Touch 将所有单指手势更改为两指手势,因此打破了自定义签名视图.

I have a custom view that captures the user's signature (John Hancock). I want our application to be as accessible as possible, so I'm taking special care to ensure to optimize our screens for TalkBack and Explore-by-Touch. Since Explore-by-Touch changes all one finger gestures into two finger gestures, it breaks the custom signature view.

我想做的是让 Explore-by-Touch 在悬停时宣布视图的内容描述,然后在用户双击时启用视图.这将允许他们像普通用户一样使用单个指针在视图顶部绘制.

What I'd like to do is have Explore-by-Touch announce the view's content description on hover, then enable the view when the user double-taps. This will allow them to draw on top of the view with a single pointer like a normal user.

我已经四处搜索,但很难找到有关 Android 辅助功能库的详细文档.有什么想法吗?

I've searched around but it's difficult to find detailed documentation on the Android accessibility libraries. Any ideas?

推荐答案

打开通过触摸浏览"时,单指触摸事件将转换为悬停事件.您可以通过将 OnHoverListener 添加到您的视图或覆盖 View.onHoverEvent.

When Explore by Touch is turned on, single-finger touch events are converted into hover events. You can watch these events by adding an OnHoverListener to your view or overriding View.onHoverEvent.

一旦您拦截了这些事件,您通常只需将它们传递给您的正常触摸处理代码,并从悬停操作映射到触摸操作(如下所示).

Once you're intercepting these events, you can usually just pass them to your normal touch handling code and map from hover actions to touch actions (as below).

@Override
public boolean onHoverEvent(MotionEvent event) {
    if (mAccessibilityManager.isTouchExplorationEnabled()) {
        return onTouchEvent(event);
    } else {
        return super.onHoverEvent(event);
    }
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_HOVER_ENTER:
            return handleDown(event);
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_HOVER_MOVE:
            return handleMove(event);
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_HOVER_EXIT:
            return handleUp(event);
    }

    return false;
}

这篇关于启用触摸浏览时如何保持单指针手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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