2012-05-07 43 views
6

我试图在我的应用程序中实现多点触控时收到了意想不到的结果。我从来没有得到多个指针的数据。 我的手机上的多点触控确实有效,因为我可以捏合放大浏览器并使用GestureDetector检测捏手势,但下面的示例打印action=0 pointers=1,无论我用多少手指触摸屏幕。MotionEvent.getPointerCount()始终为1

有什么在配置/ AndroidManifest或活动创作,我需要

@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> 

回答

19

的问题是,我回来在onTouchfalse,因此新的触摸事件有没有被生成。

+0

谢谢,谢谢,谢谢!希望这是在文档中的某处解释的。 – user1676075