I am trying to understand the following drag and resize behavior on android, but am not being able to track down. I have the following window launched in multi window free form mode [scree shot below], where if I click just outside the edge (any of the 4 sides) the window can be resized. I am trying to intercept this whole gesture (touch/ click outside the window) and drag.
I have tried setting a touch listener to the decorview obtained from the window and returning true from it to receive all further events related to this gesture.
getWindow().getDecorView().setOnTouchListener(new View.OnTouchListener() { private static final String TAG = "DVTouchListener"; @Override public boolean onTouch(View view, MotionEvent motionEvent) { Log.d(TAG,"onTouch "+motionEvent); return true; } });
But this only gets a ACTION_DOWN shortly followed by an ACTION_CANCEL (ACTION_CANCEL is received while the pointer is pressed and drag has not started even).
I tried overriding the dispatchTouchEvent of the activity and return true from there to receive all the MotionEvents of the gesture however the same is observed there too. ACTION_DOWN followed by ACTION_CANCEL.
@Override public boolean dispatchTouchEvent(MotionEvent ev) { Log.d(TAG,"dispatchTouchEvent "+ev.toString()); // return super.dispatchTouchEvent(ev); return true; }
I am not being able to understand the behavior as my understanding of the touch propagation was
if Activity.dispatchTouchEvent() returns true then it’ll consume all the subsequent gesture events (MOVE/UP). Whereas on returning false it’ll never be called again for subsequent events.
Can someone provide any hint as how to tap the whole set of MotionEvents in the gesture, or at least explain the observed behavior.
This is all because I am working on a specific use case where I need to limit the resizing ability to a single side of the window.