MotionEvent.getPointerCount () is always 1

I get unexpected results when trying to implement multitouch in my application. I never get data for more than one pointer. The multi-touch on my phone certainly works because I can increase the zoom in the browser and detect a pinch gesture with the GestureDetector, but the following samples print action=0 pointers=1 no matter how many fingers I use to touch the screen.

Is there anything in configuration / AndroidManifest or creating activity that I need

 @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; } }); } 

layout:

 <?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> 
+6
source share
1 answer

The problem was that I was returning false in onTouch , so new touch events were not generated.

+19
source

Source: https://habr.com/ru/post/915096/


All Articles