Skip to main content
This is documentation for React Native 0.82, which is no longer in active development.
For up-to-date documentation, see the latest version (0.83).
Version: 0.82

ToastAndroid

React Native's ToastAndroid API exposes the Android platform's ToastAndroid module as a JS module. It provides the method show(message, duration) which takes the following parameters:

  • message A string with the text to toast
  • duration The duration of the toastβ€”either ToastAndroid.SHORT or ToastAndroid.LONG

You can alternatively use showWithGravity(message, duration, gravity) to specify where the toast appears in the screen's layout. May be ToastAndroid.TOP, ToastAndroid.BOTTOM or ToastAndroid.CENTER.

The showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset) method adds the ability to specify an offset with in pixels.

note

Starting with Android 11 (API level 30), setting the gravity has no effect on text toasts. Read about the changes here.


Reference

Methods​

show()​

tsx
staticshow(message:string, duration:number);

showWithGravity()​

This property will only work on Android API 29 and below. For similar functionality on higher Android APIs, consider using snackbar or notification.

tsx
staticshowWithGravity(message:string, duration:number, gravity:number);

showWithGravityAndOffset()​

This property will only work on Android API 29 and below. For similar functionality on higher Android APIs, consider using snackbar or notification.

tsx
staticshowWithGravityAndOffset(
message:string,
duration:number,
gravity:number,
xOffset:number,
yOffset:number,
);

Properties​

SHORT​

Indicates the duration on the screen.

tsx
staticSHORT:number;

LONG​

Indicates the duration on the screen.

tsx
staticLONG:number;

TOP​

Indicates the position on the screen.

tsx
staticTOP:number;

BOTTOM​

Indicates the position on the screen.

tsx
staticBOTTOM:number;

CENTER​

Indicates the position on the screen.

tsx
staticCENTER:number;

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /