We can apply Gravity to the toast message to display it at various positions on the screen. Below are codes provided for displaying a Toast message at TOP, BOTTOM, RIGHT, LEFT, CENTER, TOP LEFT, and BOTTOM RIGHT positions.
// Display Toast at TOP Toast toast1 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast1.setGravity(Gravity.TOP, 0, 0); toast1.show(); // Display Toast at BOTTOM Toast toast2 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast2.setGravity(Gravity.BOTTOM, 0, 0); toast2.show(); // Display Toast on RIGHT side Toast toast3 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast3.setGravity(Gravity.RIGHT, 0, 0); toast3.show(); // Display Toast on LEFT side Toast toast4 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast4.setGravity(Gravity.LEFT, 0, 0); toast4.show(); // Display Toast in CENTER Toast toast5 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast5.setGravity(Gravity.CENTER, 0, 0); toast5.show(); // Display Toast on TOP LEFT Toast toast6 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast6.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0); toast6.show(); // Display Toast at BOTTOM RIGHT Toast toast7 = Toast.makeText(MainActivity.this, "This is my toast message.", Toast.LENGTH_SHORT); toast7.setGravity(Gravity.BOTTOM|Gravity.RIGHT, 0, 0); toast7.show();
The method used for displaying Toast at different positions is .setGravity(int gravity, int xOffset, int yOffset).
It’s іn reality а nice and һelpfuⅼ piece of information. I’m glad that you shared tһiѕ helpful information with us.
Please keep us informed like this. Thankѕ for sharing. https://sablonkaosdistrobdg.blogspot.com/
Good Informationen. Glück für ich Ichh kam in Ihre Website
Zufsll (stumbleupon). Ich habe Buch-Kennzeichnung iit für später!
Simply want to say your article is as amazing. The clarity in your post is just excellent and i can assume you are an expert on this subject.
Fine with your permission let me to grab your feed to keep up to
date with forthcoming post. Thanks a million and please carry on the
enjoyable work.
I believe that is one of the so much important information for me.
And i’m satisfied studying your article. However should statement on few normal things, The web site style is great, the articles is
actually great : D. Excellent process, cheers
As the admin of this site is working, no question very shortly it will be famous, due to
its feature contents.
We are a group of volunteers and starting a new scheme in our community.
Your website offered us with useful info to work on.
You’ve done a formidable task and our whole neighborhood might be thankful
to you.
Hello there! Quick question that’s entirely off topic.
Do you know how to make your site mobile friendly?
My blog looks weird when viewing from my iphone. I’m trying
to find a template or plugin that might be able to correct this
problem. If you have any recommendations, please share.
Cheers!
Nice post. I learn something new and challenging on sites I
stumbleupon every day. It’s always helpful to read through content
from other writers and use something from their web sites.
My programmer is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he’s tryiong none the less. I’ve been using Movable-type on several websites for about
a year and am anxious about switching to another platform.
I have heard great things about blogengine.net. Is there
a way I can transfer all my wordpress content into it? Any help would be really appreciated!