【React Native】文件翻譯閱讀紀錄 - APIs - ToastAndroid

by - 上午9:00

Facebook Open Source React Native


ToastAndroid

這將本機ToastAndroid模塊公開為JS模塊。這有一個函數'show',它帶有以下參數:

  1. 字符串消息:包含要烘烤的文本的字符串
  2. int duration:吐司的持續時間。可能是 ToastAndroid.SHORT 或 ToastAndroid.LONG
還有一個函數showWithGravity來指定佈局重力。可能是ToastAndroid.TOP,ToastAndroid.BOTTOM,ToastAndroid.CENTER。

'showWithGravityAndOffset'功能增加了指定偏移的能力。這些偏移值將轉換為像素。


基本用法:
ToastAndroid.show('A pikachu appeared nearby !', ToastAndroid.SHORT);
ToastAndroid.showWithGravity(
  'All Your Base Are Belong To Us',
  ToastAndroid.SHORT,
  ToastAndroid.CENTER
);
ToastAndroid.showWithGravityAndOffset(
  'A wild toast appeared!',
  ToastAndroid.LONG,
  ToastAndroid.BOTTOM,
  25,
  50
);

Methods

Properties


參考

Methods

show()

static show(message, duration)

showWithGravity()

static showWithGravity(message, duration, gravity)

showWithGravityAndOffset()

static showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset)

Properties

SHORT

ToastAndroid.SHORT;

LONG

ToastAndroid.LONG;

TOP

ToastAndroid.TOP;

BOTTOM

ToastAndroid.BOTTOM;

CENTER

ToastAndroid.CENTER;



You May Also Like

0 意見