Possible Duplicate:
how to change position of Toast in android?
I have to show a Toast
, when the user presses a Button
, but I want to show it a little more down on the screen
.
How can I do this?
This is the code of my Toast
:
Toast.makeText(getApplicationContext(),
getString(R.string.emailregisternotentered),
Toast.LENGTH_SHORT).show();
Solved:
Toast toast= Toast.makeText(getApplicationContext(),
getString(R.string.emailregisternotentered), Toast.LENGTH_SHORT);
//Toast.makeText(getApplicationContext(), getString(R.string.emailregisternotentered),
//Toast.LENGTH_SHORT).show();
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.show();
Positioning your Toast A standard toast notification appears near the bottom of the screen, centered horizontally. You can change this position with the setGravity(int, int, int) method. This accepts three parameters: a Gravity constant, an x-position offset, and a y-position offset.
You can prevent identical same Toast displaying in a screen by event function. You can terminate the Toast displaying process by setting cancel event property in beforeOpen Event.
A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. Toasts automatically disappear after a timeout.
In general, a Toast can be displayed for either 2 seconds (Toast. LENGTH_SHORT) or 3.5 seconds (Toast. LENGTH_LONG). In this article, we will show you how you could display Toast for longer or shorter in Android.
Here is the documentation:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html#Positioning
Toast.setGravity is one option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With