as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
Skip to main content
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.

Example


Reference

Methods

show()


showWithGravity() Vega Not Available

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

showWithGravityAndOffset() Vega Not Available

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

Properties

SHORT

Indicates the duration on the screen.

LONG

Indicates the duration on the screen.

TOP Vega Not Available

Indicates the position on the screen.

BOTTOM Vega Not Available

Indicates the position on the screen.

CENTER Vega Not Available

Indicates the position on the screen.
最后修改于 2026年11月6日