android - MotionEvent.getPointerCount() 始终为 1

标签 android multi-touch android-gesture

在我的应用程序中尝试实现多点触控时,我以某种方式得到了意想不到的结果。我从不获取超过一个指针的数据。 我手机上的多点触控确实有效,因为我可以在浏览器中捏合缩放并使用 GestureDetector 检测捏合手势,但无论我用多少手指触摸屏幕。

我需要在配置/AndroidManifest 或 Activity 创建中做些什么吗

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    findViewById(R.id.ll1).setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Log.d("TAG","onTouch action="+event.getAction()+" pointers="+event.getPointerCount());
            return false;
        }
    });
}

布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
</LinearLayout>

最佳答案

问题是我在 onTouch 中返回了 false,因此没有生成新的触摸事件。

关于android - MotionEvent.getPointerCount() 始终为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10484188/

相关文章:

Android 滑动更改 fragment 不起作用

android - 织物 Android : login with Twitter and Callback URL

android - Facebook sdk、Android 依赖项显示 facebooksdk.jar 丢失

android - 如何避免多行 TextView 中两个单词之间的文本换行?

安卓多点触控?

Android:为 android 上的多点触控应用程序获取正确的 pointerId

android - OnGestureListener.onDown()返回false的含义

android - 必须下载什么手势文件以及如何下载?

php - 无法重定向到 MainActivity 屏幕

android - 获取奇怪的触摸坐标