Keep a reference of you Toast, you can then use the cancel()
method, documentation here.
In order to know when you need to cancel the toast, you will need to intercept the touch event with the OnTouchEvent
of your activity and get the position x/y of the touch event. Then you can compare it with myToast.getView().getY()
and getX()
to get the top left corner and getWidth()
and getHeight()
.