Toasts are displayed at the bottom of the Activity Screen on Android Devices and are center-aligned. This is the default behavior of a Toast. If you wish to change the position of the Toast message that it's possible using setGravity() method.
toast.setGravity(Gravity.TOP, 0, 0);
This will display the Toast at the top of the screen above the ActionBar if implemented.
If you want to display the Toast at Top and Left then,
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
Similarly for Bottom and Right
toast.setGravity(Gravity.BOTTOM|Gravity.RIGHT, 0, 0);
To display the Toast at the Center,
toast.setGravity(Gravity.CENTER, 0, 0);
The second is third parameters can be used to set Offsets for X direction and Y direction respectively.
- Android appcompat_v7 Error retrieving parent for item: No resource found that matches the given name
- SQLite with Android Easy to Understand Tutorial that covers Select, Insert, Update and Delete
- Center align text in TextView Android Programming
- The Android Virtual Device myEmulator is currently running an emulator and cannot be deleted.
- Android Lint app_name is not translated in af (Afrikaans) am (Amharic) ar (Arabic) bg (Bulgarian)
- Android : Remove ListView Separator/divider programmatically or using xml property
- Copy Text to Android Clipboard Programmatically ClipboardManager
- How to add Newline to text in Android TextView
- How to Change Android Toast Position?
- Android AlertDialog with 3 buttons example
- Disable jQuery button after being click - jQuery
- Android xml error Attribute is missing the Android namespace prefix [Solution] - Android
- Google Webmaster : An error has occurred. Please try again later - Google
- How to Change Bootstrap Carousel Slide Speed - Bootstrap
- Increase Android Emulator Timeout time - Android
- Create a large dummy file using Mac OS X terminal command - Mac-OS-X
- How to write hello world different languages syntax - HowTos
- Enable Spellcheck in eclipse workspace - Eclipse
- Remove URL Forward Slash Before Single or Double quotes in php.ini - PHP
- Android Studio Error:(19, 0) Gradle DSL method not found: android() - Android-Studio
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net - SharePoint
- Fixed Length Android Edittext - Android
- Obsolete marquee element alternatives html5 - Html
- Update Created By (Author) column of SharePoint document using PowerShell - SharePoint
- The Android Virtual Device is currently running in an emulator and cannot be deleted - Android