我怎样才能保持一个指针手势时探索,通过触摸启用? [英] How can I maintain a one pointer gesture when explore-by-touch is enabled?

查看:332
本文介绍了我怎样才能保持一个指针手势时探索,通过触摸启用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自认为抓住了用户的签名(恒康) 。我希望我们的应用程序,以尽可能方便,所以我采取特别小心,以确保优化我们的屏幕为话语提示探索按触的。由于探索按触的改变了这一切一根手指比划成两个手指的手势,它打破了自定义签名的观点。

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.

我想要做的是有探索按触的宣布视图的悬停内容描述,然后启用观点用户双击水龙头时。这将使他们画上像一个普通用户的单一指针的观点之上。

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?

推荐答案

当触摸浏览被接通时,单指触摸事件被转换成悬停事件。您可以通过添加观看这些事件的<一个href="http://developer.android.com/reference/android/view/View.OnHoverListener.html">OnHoverListener您的视图或压倒一切的<一个href="http://developer.android.com/reference/android/view/View.html#onHoverEvent%28android.view.MotionEvent%29">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.

一旦你截获这些事件,你可以通常只是将它们传递到你的正常的触摸操作code和从悬停动作映射到触摸操作(如下图)。

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天全站免登陆