I am trying to achieve multi touch in such as way that when user pinch out with two finger outside I need to handle one event and on pinching In other event. No ZOOMING IN or ZOOMING OUT NEEDED.
So I am handling onTouchEvent on layout, but could not get conditions true for pinching in and pinching out.
Here is code,
layout.setOnTouchListener(new View.OnTouchListener() {
private int mActivePointerId;
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
mActivePointerId = motionEvent.getPointerId(0);
Log.d(TAG, "COUNT"+motionEvent.getPointerCount());
if(motionEvent.getPointerCount() > 1){
if((motionEvent.getAction() == motionEvent.ACTION_UP) && (motionEvent.getAction() == motionEvent.ACTION_POINTER_DOWN))
Log.d(TAG, "Multi Touch Upwards ");
return true;
} else if((motionEvent.getAction() == motionEvent.ACTION_DOWN) && (motionEvent.getAction() == motionEvent.ACTION_POINTER_UP)){
Log.d(TAG, "Multi Touch DownWard ");
return true;
}
else{
Log.d(TAG, "It is signal Touch");
}
return true;
}
});
I referred this link but not very clear example Any suggestion to make it work...thanks
You can make it work with the help of ScaleGestureDector
. Just need to check the scalefactor if the scale factor would be more then 1 then it would be Pinch Out otherwise Pinch In.
Here is good example, it is very easy and fits your need well, Just follow the instruction from this link ScaleGestureDector