Skip to main content
ToastAndroid is Android-only. On iOS and other platforms, it has no effect.
The ToastAndroid API exposes the native Android Toast module for displaying short notifications at the bottom of the screen. Toasts automatically disappear after a timeout.

Import

Methods

show()

Display a toast notification. Parameters:
  • message: Text to display in the toast
  • duration: Either ToastAndroid.SHORT or ToastAndroid.LONG

Example

showWithGravity()

Display a toast with custom positioning. Parameters:
  • message: Text to display
  • duration: ToastAndroid.SHORT or ToastAndroid.LONG
  • gravity: ToastAndroid.TOP, ToastAndroid.BOTTOM, or ToastAndroid.CENTER
On Android R (API 30) or later, gravity settings may not affect toast position for text toasts. This is an Android platform limitation.

Example

showWithGravityAndOffset()

Display a toast with custom positioning and pixel offsets. Parameters:
  • message: Text to display
  • duration: ToastAndroid.SHORT or ToastAndroid.LONG
  • gravity: ToastAndroid.TOP, ToastAndroid.BOTTOM, or ToastAndroid.CENTER
  • xOffset: Horizontal offset in pixels
  • yOffset: Vertical offset in pixels
On Android R (API 30) or later, gravity and offset settings may not affect toast position for text toasts.

Example

Constants

Duration Constants

Gravity Constants

Gravity constants may not have visible effects on Android R (API 30) or later when targeting that API level.

Usage Examples

Basic Toast

Toast with Gravity

Toast with Offset

Platform-Specific Toast

Notes

  • ToastAndroid only works on Android. On other platforms, calls are ignored.
  • Toasts appear above all other app content but below the system status bar.
  • Multiple toast calls will be queued and shown sequentially.
  • On Android R (API 30+), custom positioning may not work due to platform restrictions.
  • Toasts are not interactive and don’t support callbacks.
  • For important messages requiring user action, consider using Alert instead.