# Titanium.UI.Notification
A toast notification.
# Overview
A toast notification is an unobtrusive, pop-up notification that does not
block the UI. Use the Titanium.UI.createNotification method or <Notification>
Alloy element
to create a Toast notification.
On Android, by default, a toast notification appears centered on the bottom half of the screen. On Windows Phone, by default, a toast notification appears over the status bar on the top part of the screen.
# Examples
# Simple Toast Notification
The simplest use case is also the most common.
var toast = Ti.UI.createNotification({
message:"Please Stand By",
duration: Ti.UI.NOTIFICATION_DURATION_LONG
});
toast.show();
# Alloy XML Markup
Previous example as an Alloy view.
index.xml
<Alloy>
<Window>
<Notification id="toast" platform="android" message="Please Stand By" duration="Ti.UI.NOTIFICATION_DURATION_LONG" />
</Window>
</Alloy>
index.js
$.index.open();
$.toast.show();
# Properties
# duration
Determines how long the notification stays on screen.
Default: Titanium.UI.NOTIFICATION_DURATION_SHORT
# gravity
Determines the location at which the notification should appear on the screen.
- Titanium.UI.Android.GRAVITY_AXIS_CLIP
- Titanium.UI.Android.GRAVITY_AXIS_PULL_AFTER
- Titanium.UI.Android.GRAVITY_AXIS_PULL_BEFORE
- Titanium.UI.Android.GRAVITY_AXIS_SPECIFIED
- Titanium.UI.Android.GRAVITY_AXIS_X_SHIFT
- Titanium.UI.Android.GRAVITY_AXIS_Y_SHIFT
- Titanium.UI.Android.GRAVITY_BOTTOM
- Titanium.UI.Android.GRAVITY_CENTER
- Titanium.UI.Android.GRAVITY_CENTER_HORIZONTAL
- Titanium.UI.Android.GRAVITY_CENTER_VERTICAL
- Titanium.UI.Android.GRAVITY_CLIP_HORIZONTAL
- Titanium.UI.Android.GRAVITY_CLIP_VERTICAL
- Titanium.UI.Android.GRAVITY_DISPLAY_CLIP_HORIZONTAL
- Titanium.UI.Android.GRAVITY_DISPLAY_CLIP_VERTICAL
- Titanium.UI.Android.GRAVITY_END
- Titanium.UI.Android.GRAVITY_FILL
- Titanium.UI.Android.GRAVITY_FILL_HORIZONTAL
- Titanium.UI.Android.GRAVITY_FILL_VERTICAL
- Titanium.UI.Android.GRAVITY_HORIZONTAL_GRAVITY_MASK
- Titanium.UI.Android.GRAVITY_LEFT
- Titanium.UI.Android.GRAVITY_NO_GRAVITY
- Titanium.UI.Android.GRAVITY_RELATIVE_HORIZONTAL_GRAVITY_MASK
- Titanium.UI.Android.GRAVITY_RELATIVE_LAYOUT_DIRECTION
- Titanium.UI.Android.GRAVITY_RIGHT
- Titanium.UI.Android.GRAVITY_START
- Titanium.UI.Android.GRAVITY_TOP
- Titanium.UI.Android.GRAVITY_VERTICAL_GRAVITY_MASK
# horizontalMargin
Horizontal placement of the notification, as a fraction of the screen width.
Useful values range from -0.5 (far left) to 0.5 (far right). A value of zero indicates default placement.
Default: 0
# verticalMargin
Vertical placement of the notifcation, as a fraction of the screen height.
Useful values range from -0.5 (top) to 0.5 (bottom). A value of zero indicates default placement.
Default: 0