Set position of a Toast

suggest change

A standard toast notification appears at the bottom of the screen, aligned to the horizontal centre. You can change this position with setGravity(int, int, int). This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset. From Android 11, a text toast ignores setGravity. toast is not declared in this snippet.

For example, if you decide that the toast should appear in the top-left corner, you can set the gravity like this:

toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents