Set position of a Toast
suggest changeA 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);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents