androidandroid-toast

How to display Toast at center of screen


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?


Solution

  • Not Applicable after Android 11:

    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();