How do I enable multitouch support fo开发者_如何学Pythonr an app, I wish two users touching the screen and both sending drag events for the aplication.
I have this code on my component
public boolean onTouchEvent(MotionEvent evt) {
if (evt.getY() > 612) {
east.notifyMotionEvent(evt);
south.notifyMotionEvent(evt);
} else {
weast.notifyMotionEvent(evt);
north.notifyMotionEvent(evt);
}
return true;
}
But only one drag event is being send to it.
My code to support now is
for (int i = 0; i < evt.getPointerCount(); i++) {
float y = evt.getY(i);
if (y > 612) {
eastPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
southPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
} else {
weastPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
northPad.notifyMotionEvent(evt.getX(i), evt.getY(i));
}
}
It's enabled in your AndroidManifest.xml file.
<uses-feature android:name="android.hardware.touchscreen.multitouch"
android:required="true" />
More info: http://developer.android.com/guide/topics/manifest/uses-feature-element.html
精彩评论