Android cancel toast on click

I have a custom toast duplicating an image and some text. This toast is large enough to cover almost half the screen. It has a duration of LENGTH_LONG because it contains a lot of information.

In some cases, this can be a little annoying for the user. Is there a way to cancel a toast when a user clicks on it? If not, is there a way to cancel the toast by clicking anywhere outside the toast?

Thank!

+3
source share
1 answer

Keep the link to the toast, you can use the method cancel(), documentation here .

, , OnTouchEvent x/y . myToast.getView().getY() getX(), getWidth() getHeight().

+4

All Articles