About Me

My photo
Drum & Bass Producer, Software Developer, Love my Cats

Android : How to display a Toast in the middle of the screen

I wanted to show a quick message to the user so I chose a Toast. I didn't want the Toast to be in the default bottom position, so I used this snippet:

Toast toast = Toast.makeText(getApplicationContext(), "message", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);

I hope this little snippet can help you when you want to change the Android's Toast position :)