# Titanium.UI.Notification

> A toast notification.

- Source: https://titaniumsdk.com/docs/sdk/13.3.1/Titanium.UI.Notification
- Titanium SDK version: 13.3.1
- Kind: proxy
- Platforms: Android
- Since: Titanium SDK 0.8
- Extends: Titanium.Proxy
- Inheritance: Titanium.Proxy

| Android | iOS |
| ------- | --- |
| ![Android](./toast_android.png) |  |

A toast notification is an unobtrusive, pop-up notification that does not
block the UI. Use the [Titanium.UI.createNotification](https://titaniumsdk.com/docs/sdk/Titanium.UI.md#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.

## Example: Simple Toast Notification

The simplest use case is also the most common.

``` js
var toast = Ti.UI.createNotification({
    message:"Please Stand By",
    duration: Ti.UI.NOTIFICATION_DURATION_LONG
});
toast.show();
```

## Example: Alloy XML Markup

Previous example as an Alloy view.

index.xml
``` xml
<Alloy>
    <Window>
        <Notification id="toast" platform="android" message="Please Stand By" duration="Ti.UI.NOTIFICATION_DURATION_LONG" />
    </Window>
</Alloy>
```

index.js
``` js
$.index.open();
$.toast.show();
```

## Properties

### duration

- Type: Number
- Platforms: Android
- Default: `<Titanium.UI.NOTIFICATION_DURATION_SHORT>`

Determines how long the notification stays on screen.

Accepts: `Titanium.UI.NOTIFICATION_DURATION_LONG`, `Titanium.UI.NOTIFICATION_DURATION_SHORT`

### gravity

- Type: Number
- Platforms: Android
- Since: Titanium SDK 5.4.0

Determines the location at which the notification should appear on the screen.

Accepts: `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

- Type: Number
- Platforms: Android
- Default: `0`

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.

### message

- Type: String
- Platforms: Android

Notification text to display.

### verticalMargin

- Type: Number
- Platforms: Android
- Default: `0`

Vertical placement of the notification, *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.

### xOffset

- Type: Number
- Platforms: Android
- Default: `0`

X offset from the default position, in pixels.

### yOffset

- Type: Number
- Platforms: Android
- Default: `0`

Y offset from the default position, in pixels.

## Methods

### show

- Platforms: Android

Show the notification.

## Inherited members

7 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/13.3.1/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

