Android的onTouchListener停止接收的事件时,手指上移 [英] Android onTouchListener stops receiving events when finger is moved up

查看:582
本文介绍了Android的onTouchListener停止接收的事件时,手指上移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的活动分配给它的下列OnTouchListener的自定义视图:

I have a custom view with the following OnTouchListener assigned to it in my activity:

private OnTouchListener MyOnTouchListener = new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        System.out.println("onTouch called.");
        System.out.println("x" + event.getX() + ", y: " + event.getY());
        return true;
    }
};

如预期,直到用户超过​​几像素移动手指向上或向下更多这寄存器和显示事件在日志中。此后,直到用户移除并重新应用他们的手指没有触摸事件被传递给听者。然而,使用亚行外壳getevent 显示,仍然被生成的事件。在LogCat中输出,具有注释的一个例子,可以在 http://pastebin.com/7EBM2X4V 被发现。

This registers and displays events in the log as expected, until the user moves their finger up or down more than a few pixels. After this, no touch events are passed to the listener until the user removes and reapplies their finger. However, using adb shell getevent shows that events are still being generated. An example of the LogCat output, with annotations, can be found at http://pastebin.com/7EBM2X4V.

问题不是手指去视图的范围之外。

The issue is not that the finger goes outside the bounds of the view.

有谁知道为什么我有这样的行为?

Does anyone know why I have this behaviour?

推荐答案

原来的问题是,该视图包含在滚动型。卸下滚动型解决问题。

It turns out the issue is that the view is contained in a ScrollView. Removing the ScrollView fixes the problem.

这篇关于Android的onTouchListener停止接收的事件时,手指上移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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