In Android I want to display a toast message at the bottom of the screen, I tried this:
Toast.makeText(test.this, "bbb", Toast.LENGTH_LONG).show();
It doesn't work, how do I do it correctly?
To display the Toast in center of the screen. If someone wants to adjust the position further, the third argument in setGravity takes in the yAxis offset in pixels. setGravity() should have returned Toast to be able to chain it.
Display the created Toast Message using the show() method of the Toast class. The code to show the Toast message: Toast. makeText(getApplicationContext(), "This a toast message", Toast.
A Toast in Android is a message that appears on the screen for a specific time whenever invoked. This message appears at the bottom of the application leaving some margin at the bottom. In general, a Toast can be displayed for either 2 seconds (Toast. LENGTH_SHORT) or 3.5 seconds (Toast.
To display the Toast in center of the screen.
Toast toast = Toast.makeText(test.this, "bbb", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();
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