# Titanium.UI.Window

The Window is an empty drawing surface or container.

Availability
0.9
0.9
9.2.0

# Overview

To create a window, use the Titanium.UI.createWindow method or a <Window> Alloy element.

A window is a top-level container which can contain other views. Windows can be opened and closed. Opening a window causes the window and its child views to be added to the application's render stack, on top of any previously opened windows. Closing a window removes the window and its children from the render stack.

Windows contain other views, but in general they are not contained inside other views. There are a few specialized views that manage windows:

By default, windows occupy the entire screen except for the navigation bar, status bar, and in the case of windows contained in tab groups, the tab bar. To take up the entire screen, covering any other UI, specify fullscreen:true when creating the window.

# Pass Context Between Windows

To pass data between windows, use a CommonJS module (opens new window) to save information from one window then retrieve it in another. In the example below, the foo module exposes two methods to store and retrieve an object. The first window of the project loads the foo module and uses the set method to store some data before opening the second window. The second window loads the same module and is able to retrieve the content saved by the first window with the get method.

Note that for Alloy projects, you can simply pass the context as the second argument of the Alloy.createController method, then retrieve the data with the special variable $.args in the controller code.

app/lib/foo.js:

// For a classic Titanium project, save the file to 'Resources/foo.js'
var data = {};
function setData (obj){
    data = obj;
}
function getData () {
    return data;
}

// The special variable 'exports' exposes the functions as public
exports.setData = setData;
exports.getData = getData;

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue">
        <Label onClick="openWindow">Open the Red Window!</Label>
    </Window>
</Alloy>

app/controllers/index.js:

var foo = require('foo');
foo.setData({foobar: 42});

function openWindow () {
    var win2 = Alloy.createController('win2').getView();
    // For Alloy projects, you can pass context
    // to the controller in the Alloy.createController method.
    // var win2 = Alloy.createController('win2', {foobar: 42}).getView();
    win2.open();
}

$.index.open();

app/views/win2.xml:

<Alloy>
    <Window backgroundColor="red">
        <Label id="label">I am a red window.</Label>
    </Window>
</Alloy>

app/controllers/win2.js:

var foo = require('foo');
$.label.text = foo.getData().foobar;

// For Alloy projects, you can also pass in context
// with the Alloy.createController method and retrieve
// it in the controller code.
// $.label.text = $.args.foobar;

In the user interface, a modal window is a window that blocks the main application UI until the modal window is dismissed. A modal window requires the user to interact with it to resume the normal flow of the application. For example, if an action requires the user to login, the application can present a login window, then after the user is authenticated, the normal flow of the application can be resumed.

To create a modal window, set the modal property to true in the dictionary passed to either the Titanium.UI.createWindow() method or the Window object's open() method.

# Android Behavior

The Android platform does not has the concept of a modal window but instead uses modal dialogs. You are probably looking for a Titanium.UI.AlertDialog or Titanium.UI.OptionDialog and the androidView property rather than a modal window.

However, if you know what you are doing and use modal, Titanium creates a window with a translucent background (if the background properties are not set).

The combination of fullscreen:true and modal:true will not work as expected. If the background window displays the status bar or action bar, it will be visible behind the modal window.

Note that Titanium will allow a non-modal window to open on top of a modal window on Android.

# iOS Behavior

By default, if you do not set a backgroundColor, the modal's background color will be the value set to Titanium.UI.backgroundColor.

The modal window will not show the background window stack even if you make the modal translucent. For fullscreen modals, when the modal appears, the background window stack is removed. For non-fullscreen modals on the iPad, the background will be opaque gray if a background color is not specified.

By default, modal windows appear from the bottom of the screen and slide up. To change the default transition, set the modalTransitionStyle property to a Titanium.UI.iOS.MODAL_TRANSITION_STYLE_* constant in the dictionary passed to the Window object's open() method.

Modal windows should not support orientation modes that the window they are opened over do not support. Doing otherwise may cause bad visual/redraw behavior after the modal is dismissed, due to how iOS manages modal transitions.

Starting with Release 3.1.3, if the orientationModes property of a modal window is undefined, then the orientations supported by this window would be the orientation modes specified by the tiapp.xml with the UISupportedInterfaceOrientations key.

iOS does not allow opening non-modal windows on top of a modal window.

# iPad Features

In addition to full-screen modal windows, iPad supports "Page sheet" and "Form sheet" style windows:

  • Page sheet style windows have a fixed width, equal to the width of the screen in portait mode, and a height equal to the current height of the screen. This means that in portrait mode, the window covers the entire screen. In landscape mode, the window is centered on the screen horizontally.

  • Form sheet style windows are smaller than the screen size, and centered on the screen.

The example below is a modal window using the Form sheet style:

You can create this type of modal window on iPad with the following code snippet:

var win = Ti.UI.createNavigationWindow({
    window: Ti.UI.createWindow({
        title: "Modal Window"
    })
});

win.open({
    modal: true,
    modalTransitionStyle: Ti.UI.iOS.MODAL_TRANSITION_STYLE_FLIP_HORIZONTAL,
    modalStyle: Ti.UI.iOS.MODAL_PRESENTATION_FORMSHEET
});

# Animations

Windows can be animated like a Titanium.UI.View, such as using an animation to open or close a window. The example below creates a window that opens from small to large with a bounce effect. This is done by applying a transformation at initialization time that scales the original size of the window to 0. When the window is opened, a new 2D transformation is applied that will scale the window size from 0 to 110% of it's original size, then, after 1/20th of a second, it is scaled back to it's original size at 100%. This gives the bounce effect during animation.

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue" onPostlayout="animateOpen" >
        <Label color="orange">Animated Window</Label>
    </Window>
</Alloy>

app/controllers/index.js:

$.index.transform = Titanium.UI.createMatrix2D().scale(0);
$.index.open();

var a = Ti.UI.createAnimation({
    transform : Ti.UI.createMatrix2D().scale(1.1),
    duration : 2000,
});
a.addEventListener('complete', function() {
    $.index.animate({
        transform: Ti.UI.createMatrix2D(),
        duration: 200
    });
});

function animateOpen() {
    $.index.animate(a);
}

Note that to animate an Android window while you open it, you need to follow a specific procedure which is explained below in "Window Transitions in Android".

# iOS Platform Notes

# iOS Transition Animations

iOS contains built-in transition animations when switching between non-modal windows. In the Window's open method, set the transition property to a Titanium.UI.iOS.AnimationStyle constant to use an animation. For example, to flip right-to-left between two windows:

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue" onOpen="animateOpen">
        <Label id="label">I am a blue window!</Label>
    </Window>
</Alloy>

app/controllers/index.js

function animateOpen() {
    Alloy.createController('win2').getView().open({
        transition: Ti.UI.iOS.AnimationStyle.FLIP_FROM_LEFT
    });
}
$.index.open();

app/views/win2.xml:

<Alloy>
    <Window backgroundColor="red">
        <Label id="label">I am a red window!</Label>
    </Window>
</Alloy>

In the above example, the red window will be animated from the right-to-left over the blue window.

You can create transition animations when opening and closing windows in either a Titanium.UI.iOS.NavigationWindow or Titanium.UI.Tab.

Use the Titanium.UI.iOS.createTransitionAnimation method to specify an animation objects to hide and show the window, then set the newly created TransitionAnimation object to the window's Titanium.UI.Window.transitionAnimation property.

In the example below, the windows are closed by rotating them upside down while simulatenously making them transparent:

app/views/index.xml:

<Alloy>
    <NavigationWindow platform="ios">
        <Window id="redwin" title="Red Window" backgroundColor="red">
            <Button id="button" onClick="openBlueWindow">Open Blue Window</Button>
        </Window>
    </NavigationWindow>
</Alloy>

app/controllers/index.js:

function openBlueWindow(e) {
    var bluewin = Alloy.createController('bluewin').getView();
    $.index.openWindow(bluewin);
}

$.redwin.transitionAnimation = Ti.UI.iOS.createTransitionAnimation({
    duration: 300,
    // The show transition makes the window opaque and rotates it correctly
    transitionTo: {
        opacity: 1,
        duration: 300,
        transform: Ti.UI.createMatrix2D()
    },
    // The hide transition makes the window transparent and rotates it upside down
    transitionFrom: {
        opacity: 0,
        duration: 300 / 2,
        transform: Ti.UI.createMatrix2D().rotate(180),
    }
});

$.index.open();

app/views/bluewin.xml:

<Alloy>
    <Window title="Blue Window" backgroundColor="blue" opacity="0">
        <Button onClick="closeWindow">Close Window</Button>
    </Window>
</Alloy>

app/controllers/bluewin.js:

function closeWindow(){
    $.bluewin.close();
}

$.bluewin.transitionAnimation = Ti.UI.iOS.createTransitionAnimation({
    duration: 300,
    // The show transition makes the window opaque and rotates it correctly
    transitionTo: {
        opacity: 1,
        duration: 300,
        transform: Ti.UI.createMatrix2D()
    },
    // The hide transition makes the window transparent and rotates it upside down
    transitionFrom: {
        opacity: 0,
        duration: 300 / 2,
        transform: Ti.UI.createMatrix2D().rotate(180),
    }
});

$.bluewin.transform = Ti.UI.createMatrix2D().rotate(180);

# Android Platform Notes

# Window Transitions in Android

A window is associated with a new Android Titanium.Android.Activity. The only way to animate the opening or closing of an Activity in Android is to apply an animation resource to it. Passing a Titanium.UI.Animation object as a parameter to Titanium.UI.Window.open or Titanium.UI.Window.close will have no effect.

Instead, in the parameter dictionary you pass to Titanium.UI.Window.open or Titanium.UI.Window.close, you should set the activityEnterAnimation and activityExitAnimation keys to animation resources. activityEnterAnimation should be set to the animation you want to run on the incoming activity, while activityExitAnimation should be set to the animation you want to run on the outgoing activity that you are leaving.

Animation resources are available through the R object. Use either Titanium.Android.R for built-in resources or Titanium.App.Android.R for resources that you package in your application.

As an example, you may wish for the window that you are opening to fade in while the window you are leaving should fade out:

var win2 = Ti.UI.createWindow();
win2.open({
    activityEnterAnimation: Ti.Android.R.anim.fade_in,
    activityExitAnimation: Ti.Android.R.anim.fade_out
});

See the official Android R.anim (opens new window) documentation for information about built-in animations.

For information on creating your own animation resource XML files, see "View Animation (opens new window)" in Android's Resources documentation. After creating an animation resource file, you can place it under platform/android/res/anim in your Titanium project folder and it will be packaged in your app's APK and then available via Titanium.App.Android.R.

# Material design transitions in Android

You can provide transition between common elements among participating activities. For example in a master-detail pattern, clicking on a row item animates the common elements of image, title smoothly into details activity as if they are part of the same scene. This seamless animation is called shared element transition and can be achieved by the following steps.

Say window A is opening window B. Firstly, specify a unique transitionName to the common UI elements between the two windows. Next use addSharedElement method on window B passing the window A common UI element and the transition name. This tells the system which views are shared between windows and performs the transition between them. Note that we specify the UI elements of window A since the system needs the source element and connects the destination element from the shared transition name once window B is created and shown.

For example to transition a preview ImageView in window A to a full-width ImageView in window B.

const windowA = Ti.UI.createWindow({
  title: "overview"
});

// Create an item in window A with a unique transitionName.
const viewA = Ti.UI.createImageView({
  top: 10,
  left: 10,
  scalingMode: Titanium.Media.IMAGE_SCALING_ASPECT_FILL,
  image: "https://api.lorem.space/image/shoes?w=500&h=500",
  height: 100,
  width: 100,
  transitionName: 'title'
});

const btn = Ti.UI.createButton({
  bottom: 10,
  title: "open new window"
})

btn.addEventListener("click", function() {
  // Before opening window B specify the common UI elements.
  windowB.addSharedElement(viewA, "title");
  windowB.open();

  windowB.activity.onCreate = () => {
    const actionBar = windowB.activity.actionBar;
    if (actionBar) {
      actionBar.displayHomeAsUp = true;
      actionBar.title = "New Title";
      actionBar.onHomeIconItemSelected = () => {
        windowB.close();
      };
    }
  };
})
windowA.add([viewA, btn]);
windowA.open();

// Creating an item in window B, note that the same transitionName is used.
const windowB = Ti.UI.createWindow({});
const viewB = Ti.UI.createImageView({
  scalingMode: Titanium.Media.IMAGE_SCALING_ASPECT_FILL,
  top: 0,
  left: 0,
  image: "https://api.lorem.space/image/shoes?w=500&h=500",
  height: 200,
  width: Ti.UI.FILL,
  transitionName: 'title'
});
const labelB = Ti.UI.createLabel({
  top: 210,
  left: 10,
  text: "Detail window"
})
windowB.add([viewB, labelB]);

Further you can use activityEnterTransition, activityExitTransition, activityReenterTransition and activityReturnTransition to customize the way activities transition into the scene. These are intended to be used with views set up as "shared elements" via the addSharedElement() method where these views will be moved from window to the other. As of Titanium 8.0.1, you don't have to add views as shared elements to use these transition animations, while in older version of Titanium that was required.

See the official Android Activity Transitions (opens new window) documentation for more information and supported transitons.

# Android "root" Windows

In Android, you may wish to specify that a window which you create (such as the first window) should be considered the root window and that the application should exit when the back button is pressed from that window. This is particularly useful if your application is not using a Tab Group and therefore the splash screen window is appearing whenever you press the back button from your lowest window on the stack.

To indicate that a particular window should cause an application to exit when the back button is pressed, pass exitOnClose: true as one of the creation arguments, as shown here:

var win = Titanium.UI.createWindow({
  title: 'My Root Window',
  exitOnClose: true
});

Starting with Release 3.2.0, the root window's exitOnClose property is set to true by default. Prior to Release 3.2.0, the default value of the property was false for all windows.

# Examples

# Full Screen Window example

Create a fullscreen window with a red background.

var window = Titanium.UI.createWindow({
    backgroundColor:'red'
});
window.open({fullscreen:true});

# Alloy XML Markup

Previous example as an Alloy view.

<Alloy>
    <Window id="win" backgroundColor="red" fullscreen="true" />
</Alloy>

# Properties

# accessibilityDisableLongPress CREATION ONLY

Availability
12.4.0
accessibilityDisableLongPress :Boolean

Boolean value to remove the long press notification for the device's accessibility service.

Will disable the "double tap and hold for long press" message when selecting an item.

Default: true


# accessibilityHidden

Availability
3.0.0
3.0.0
9.2.0
accessibilityHidden :Boolean

Whether the view should be "hidden" from (i.e., ignored by) the accessibility service.

On iOS this is a direct analog of the accessibilityElementsHidden property defined in the UIAccessibility Protocol.

On Android, setting accessibilityHidden calls the native View.setImportantForAccessibility method. The native method is only available in Android 4.1 (API level 16/Jelly Bean) and later; if this property is specified on earlier versions of Android, it is ignored.

Default: false


# accessibilityHint

Availability
3.0.0
3.0.0
9.2.0
accessibilityHint :String

Briefly describes what performing an action (such as a click) on the view will do.

On iOS this is a direct analog of the accessibilityHint property defined in the UIAccessibility Protocol. On Android, it is concatenated together with accessibilityLabel and accessibilityValue in the order: accessibilityLabel, accessibilityValue, accessibilityHint. The concatenated value is then passed as the argument to the native View.setContentDescription method.

Default: null


# accessibilityLabel

Availability
3.0.0
3.0.0
9.2.0
accessibilityLabel :String

A succint label identifying the view for the device's accessibility service.

On iOS this is a direct analog of the accessibilityLabel property defined in the UIAccessibility Protocol. On Android, it is concatenated together with accessibilityValue and accessibilityHint in the order: accessibilityLabel, accessibilityValue, accessibilityHint. The concatenated value is then passed as the argument to the native View.setContentDescription method. Defaults to Title or label of the control.


# accessibilityValue

Availability
3.0.0
3.0.0
9.2.0
accessibilityValue :String

A string describing the value (if any) of the view for the device's accessibility service.

On iOS this is a direct analog of the accessibilityValue property defined in the UIAccessibility Protocol. On Android, it is concatenated together with accessibilityLabel and accessibilityHint in the order: accessibilityLabel, accessibilityValue, accessibilityHint. The concatenated value is then passed as the argument to the native View.setContentDescription method. Defaults to State or value of the control.


# activity READONLY

Availability
0.9

Contains a reference to the Android Activity object associated with this window.

An Activity object is not created until the window is opened. Before the window is opened, activity refers to an empty JavaScript object. You can be set properties on this object, but cannot invoke any Activity methods on it. Once the window is opened, the actual Activity object is created, using any properties set on the JavaScript object. At this point, you can call methods on the activity and access any properties that are set when the activity is created, for example, actionBar.


# activityEnterTransition CREATION ONLY

Availability
5.2.0
activityEnterTransition :Number

The type of transition used when activity is entering.

Activity B's enter transition determines how views in B are animated when A starts B. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses platform theme transition.


# activityExitTransition CREATION ONLY

Availability
5.2.0
activityExitTransition :Number

The type of transition used when activity is exiting.

Activity A's exit transition determines how views in A are animated when A starts B. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses platform theme transition.


# activityReenterTransition CREATION ONLY

Availability
5.2.0
activityReenterTransition :Number

The type of transition used when reentering to a previously started activity.

Activity A's reenter transition determines how views in A are animated when B returns to A. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses `activityExitTransition`.


# activityReturnTransition CREATION ONLY

Availability
5.2.0
activityReturnTransition :Number

The type of transition used when returning from a previously started activity.

Activity B's return transition determines how views in B are animated when B returns to A. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses `activityEnterTransition`.


# activitySharedElementEnterTransition CREATION ONLY

Availability
5.2.0
activitySharedElementEnterTransition :Number

The type of enter transition used when animating shared elements between two activities.

Activity B's shared element enter transition determines how shared elements animate from A to B. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementExitTransition CREATION ONLY

Availability
5.2.0
activitySharedElementExitTransition :Number

The type of exit transition used when animating shared elements between two activities.

Activity A's shared element exit transition animates shared elements before they transition from A to B Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementReenterTransition CREATION ONLY

Availability
5.2.0
activitySharedElementReenterTransition :Number

The type of reenter transition used when animating shared elements between two activities.

Activity A's shared element reenter transition animates shared elements after they have transitioned from B to A. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementReturnTransition CREATION ONLY

Availability
5.2.0
activitySharedElementReturnTransition :Number

The type of return transition used when animating shared elements between two activities.

Activity B's shared element return transition determines how shared elements animate from B to A. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# anchorPoint

Availability
7.5.0
2.1.0
9.2.0
anchorPoint :Point

Coordinate of the view about which to pivot an animation.

Used on iOS only. For Android, use anchorPoint.

Anchor point is specified as a fraction of the view's size. For example, {0, 0} is at the view's top-left corner, {0.5, 0.5} at its center and {1, 1} at its bottom-right corner.

See the "Using an anchorPoint" example in Titanium.UI.Animation for a demonstration. The default is center of this view.


# animatedCenter READONLY

Availability
0.9
9.2.0
animatedCenter :Point

Current position of the view during an animation.


# apiName READONLY

Availability
3.2.0
3.2.0
9.2.0
apiName :String

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Titanium.UI.Button returns Ti.UI.Button.


# autoAdjustScrollViewInsets

Availability
3.1.3
9.2.0
autoAdjustScrollViewInsets :Boolean

Specifies whether or not the view controller should automatically adjust its scroll view insets.

When the value is true, it allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, toolbar and tab bar.

The default behavior assumes that this is false. Must be specified before opening the window.


# backButtonTitle

Availability
0.9
9.2.0
backButtonTitle :String

Title for the back button. This is only valid when the window is a child of a tab.


# backButtonTitleImage

Availability
0.9
9.2.0
backButtonTitleImage :String | Titanium.Blob

The image to show as the back button. This is only valid when the window is a child of a tab.


# backgroundColor

Availability
0.9
0.9
9.2.0
backgroundColor :String | Titanium.UI.Color

Background color of the window, as a color name or hex triplet.

On Android, to specify a semi-transparent background, set the alpha value using the opacity property before opening the window.

For information about color values, see the "Colors" section of Titanium.UI.

Default: Transparent


# backgroundDisabledColor

Availability
0.9
backgroundDisabledColor :String

Disabled background color of the view, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI. Defaults to the normal background color of this view.


# backgroundDisabledImage

Availability
0.9
backgroundDisabledImage :String

Disabled background image for the view, specified as a local file path or URL.

If backgroundDisabledImage is undefined, and the normal background imagebackgroundImage is set, the normal image is used when this view is disabled.


# backgroundFocusedColor

Availability
0.9
backgroundFocusedColor :String

Focused background color of the view, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI.

For normal views, the focused color is only used if focusable is true. Defaults to the normal background color of this view.


# backgroundFocusedImage

Availability
0.9
backgroundFocusedImage :String

Focused background image for the view, specified as a local file path or URL.

For normal views, the focused background is only used if focusable is true. If backgroundFocusedImage is undefined, and the normal background image backgroundImage is set, the normal image is used when this view is focused.


# backgroundGradient

Availability
0.9
0.9
9.2.0
backgroundGradient :Gradient

A background gradient for the view.

A gradient can be defined as either linear or radial. A linear gradient varies continuously along a line between the startPoint and endPoint.

A radial gradient is interpolated between two circles, defined by startPoint and startRadius and endPoint and endRadius respectively.

The start points, end points and radius values can be defined in device units, in the view's coordinates, or as percentages of the view's size. Thus, if a view is 60 x 60, the center point of the view can be specified as:

{ x: 30, y: 30 }

Or:

{ x: '50%', y: '50%' }

When specifying multiple colors, you can specify an offset value for each color, defining how far into the gradient it takes effect. For example, the following color array specifies a gradient that goes from red to blue back to red:

colors: [ { color: 'red', offset: 0.0}, { color: 'blue', offset: 0.25 }, { color: 'red', offset: 1.0 } ]

Android's linear gradients ignores backfillStart and backfillEnd, treating them as if they are true. Android's radial gradients ignore the endPoint property. Defaults to no gradient.


# backgroundImage

Availability
0.9
0.9
9.2.0
backgroundImage :String

Background image for the view, specified as a local file path or URL.

Default behavior when backgroundImage is unspecified depends on the type of view and the platform. For generic views, no image is used. For most controls (buttons, textfields, and so on), platform-specific default images are used.


# backgroundLeftCap

Availability
0.9
9.2.0
backgroundLeftCap :Number

Size of the left end cap.

See the section on backgroundLeftCap and backgroundTopCap behavior on iOS in Titanium.UI.View.

Default: 0


# backgroundRepeat

Availability
0.9
0.9
9.2.0
backgroundRepeat :Boolean

Determines whether to tile a background across a view.

Setting this to true makes the set backgroundImage repeat across the view as a series of tiles. The tiling begins in the upper-left corner, where the upper-left corner of the background image is rendered. The image is then tiled to fill the available space of the view.

Note that setting this to true may incur performance penalties for large views or background images, as the tiling must be redone whenever a view is resized.

On iOS, the following views do not currently support tiled backgrounds:

Default: false


# backgroundSelectedColor

Availability
0.9
backgroundSelectedColor :String | Titanium.UI.Color

Selected background color of the view, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI.

focusable must be true for normal views.

Defaults to background color of this view.


# backgroundSelectedImage

Availability
0.9
backgroundSelectedImage :String

Selected background image url for the view, specified as a local file path or URL.

For normal views, the selected background is only used if focusable is true.

If backgroundSelectedImage is undefined, and the normal background image backgroundImage is set the normal image is used when this view is selected.


# backgroundTopCap

Availability
0.9
9.2.0
backgroundTopCap :Number

Size of the top end cap.

See the section on backgroundLeftCap and backgroundTopCap behavior on iOS in Titanium.UI.View.

Default: 0


# barColor

Availability
8.0.1
0.9
9.2.0
barColor :String | Titanium.UI.Color

Background color for the nav bar, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI.


# barImage

Availability
0.9
9.2.0
barImage :String

Background image for the nav bar, specified as a URL to a local image.

The behavior of this API on iOS has changed from version 3.2.0. Previous versions of the SDK created a custom image view and inserted it as a child of the navigation bar. The titanium sdk now uses the native call to set the background image of the navigation bar. You can set it to a 1px transparent png to use a combination of barColor and hideShadow:true.


# borderColor

Availability
0.9
0.9
9.2.0
borderColor :String | Titanium.UI.Color

Border color of the view, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI.

Defaults to the normal background color of this view (Android), black (iOS).


# borderRadius

Availability
0.9
0.9
9.2.0
borderRadius :Number | String | Array<Number> | Array<String>

Radius for the rounded corners of the view's border.

Each corner is rounded using an arc of a circle. Values for each corner can be specified. For example, '20px 20px' will set both left and right corners to 20px. Specifying '20px 20px 20px 20px' will set top-left, top-right, bottom-right and bottom-left corners in that order.

If you have issues with dark artifacts on Android you can try to disable Hardware acceleration by setting a backgroundColor with a small amount of transparency: backgroundColor:"rgba(255,255,255,254)".

Default: 0


# borderWidth

Availability
0.9
0.9
9.2.0
borderWidth :Number

Border width of the view.

If borderColor is set without borderWidth, this value will be changed to 1 of the unit declared as 'ti.ui.defaultunit' in tiapp.xml descriptor.

Default: 0


# bottom

Availability
0.9
0.9
9.2.0
bottom :Number | String

Window's bottom position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# bubbleParent

Availability
3.0.0
3.0.0
9.2.0
bubbleParent :Boolean

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true


# center

Availability
0.9
0.9
9.2.0
center :Point

View's center position, in the parent view's coordinates.

This is an input property for specifying where the view should be positioned, and does not represent the view's calculated position.

Defaults to undefined.


# children READONLY

Availability
0.9
0.9
9.2.0
children :Array<Titanium.UI.View>

Array of this view's child views.


# clipMode

Availability
3.3.0
9.2.0
clipMode :Number

View's clipping behavior.

Setting this to CLIP_MODE_ENABLED enforces all child views to be clipped to this views bounds. Setting this to CLIP_MODE_DISABLED allows child views to be drawn outside the bounds of this view. When set to CLIP_MODE_DEFAULT or when this property is not set, clipping behavior is inferred. See section on iOS Clipping Behavior in Titanium.UI.View.

Defaults to undefined. Behaves as if set to CLIP_MODE_DEFAULT.


# closed READONLY

Availability
9.1.0
9.1.0
9.2.0
closed :Boolean

Determines whether this Window is closed.

Default: true


# elevation

Availability
5.0.0
elevation :Number

Base elevation of the view relative to its parent in pixels.

The elevation of a view determines the appearance of its shadow. Higher elevations produce larger and softer shadows.

Note: The elevation property only works on Titanium.UI.View objects. Many Android components have a default elevation that cannot be modified. For more information, see Google design guidelines: Elevation and shadows.


# exitOnClose

Availability
0.9
exitOnClose :Boolean

Boolean value indicating if the application should exit when the Android Back button is pressed while the window is being shown or when the window is closed programmatically.

Starting in 3.4.2 you can set this property at any time. In earlier releases you can only set this as a createWindow({...}) option.

Default: true if this is the first window launched else false; prior to Release 3.3.0, the default was always false.


# extendEdges

Availability
3.1.3
9.2.0
extendEdges :Array<Number>

An array of supported values specified using the EXTEND_EDGE constants in Titanium.UI.

This is only valid for windows hosted by navigation controllers or tab bar controllers. This property is used to determine the layout of the window within its parent view controller. For example if the window is specified to extend its top edge and it is hosted in a navigation controller, then the top edge of the window is extended underneath the navigation bar so that part of the window is obscured. If the navigation bar is opaque (translucent property on window is false), then the top edge of the window will only extend if includeOpaqueBars is set to true.

The default behavior is to assume that no edges are to be extended. Must be specified before opening the window.


# extendSafeArea CREATION ONLY

Availability
7.5.0
6.3.0
9.2.0
extendSafeArea :Boolean

Specifies whether the screen insets/notches are allowed to overlap the window's content or not.

If set true, then the contents of the window will be extended to fill the whole screen and allow the system's UI elements (such as a translucent status-bar) and physical obstructions (such as the iPhone X rounded corners and top sensor housing) to overlap the window's content. In this case, it is the app developer's responsibility to position views so that they're unobstructed. On Android, you can use the safeAreaPadding property after the window has been opened to layout your content within the insets.

If set false, then the window's content will be laid out within the safe-area and its child views will be unobstructed. For example, you will not need to position a view below the top status-bar.

Read more about the safe-area layout-guide in the Human Interface Guidelines.

Default: `false` on Android, `true` on iOS.


# filterTouchesWhenObscured

Availability
9.3.0
filterTouchesWhenObscured :Boolean

Discards touch related events if another app's system overlay covers the view.

This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay.

Setting this property to true causes touch related events (including "click") to not be fired if a system overlay overlaps the view.

Default: false


# flagSecure CREATION ONLY

Availability
3.3.0
flagSecure :Boolean

Treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.

When the value is true, preventing it from appearing in screenshots or from being viewed on non-secure displays.

Default: false


# focusable

Availability
0.9
focusable :Boolean

Whether view should be focusable while navigating with the trackball.

Default: false


# focused READONLY

Availability
9.1.0
9.1.0
9.2.0
focused :Boolean

Determines whether this TextArea has focus.

Default: false


# fullscreen

Availability
0.9
0.9
9.2.0
fullscreen :Boolean

Boolean value indicating if the window is fullscreen.

A fullscreen window occupies all of the screen space, hiding the status bar. Must be specified at creation time or in the options dictionary passed to the open method.

On iOS the behavior of this property has changed. Starting from 3.1.3, if this property is undefined then the property is set to the value for UIStatusBarHidden defined in tiapp.xml. If that is not defined it is treated as explicit false. On earlier versions, opening a window with this property undefined would not effect the status bar appearance.

Default: false


# height

Availability
0.9
0.9
9.2.0
height :Number | String

View height, in platform-specific units.

Defaults to: If undefined, defaults to either FILL or SIZE depending on the view. See "View Types and Default Layout Behavior" in Transitioning to the New UI Layout System.

Can be either a float value or a dimension string (for example, '50%' or '40dp'). Can also be one of the following special values:

  • SIZE. The view should size itself to fit its contents.
  • FILL. The view should size itself to fill its parent.
  • 'auto'. Represents the default sizing behavior for a given type of view. The use of 'auto' is deprecated, and should be replaced with the SIZE or FILL constants if it is necessary to set the view's behavior explicitly.

This is an input property for specifying the view's height dimension. To determine the view's size once rendered, use the rect or size properties.

This API can be assigned the following constants:

# hiddenBehavior

Availability
6.1.0
hiddenBehavior :Number

Sets the behavior when hiding an object to release or keep the free space

If setting hiddenBehavior to HIDDEN_BEHAVIOR_GONE it will automatically release the space the view occupied. For example: in a vertical layout the views below the object will move up when you hide an object with hiddenBehavior:Titanium.UI.HIDDEN_BEHAVIOR_GONE.

Defaults to Titanium.UI.HIDDEN_BEHAVIOR_INVISIBLE.

This API can be assigned the following constants:

# hidesBackButton

Availability
8.0.0
7.5.0
9.2.0
hidesBackButton :Boolean

Set this to true to hide the back button of navigation bar.

When this property is set to true, the navigation window hides its back button.

Default: false


# hidesBarsOnSwipe CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsOnSwipe :Boolean

Set this to true to hide the navigation bar on swipe.

When this property is set to true, an upward swipe hides the navigation bar and toolbar. A downward swipe shows both bars again. If the toolbar does not have any items, it remains visible even after a swipe.

Default: false


# hidesBarsOnTap CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsOnTap :Boolean

Set this to true to hide the navigation bar on tap.

When the value of this property is true, the navigation controller toggles the hiding and showing of its navigation bar and toolbar in response to an otherwise unhandled tap in the content area.

Default: false


# hidesBarsWhenKeyboardAppears CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsWhenKeyboardAppears :Boolean

Set this to true to hide the navigation bar when the keyboard appears.

When this property is set to true, the appearance of the keyboard causes the navigation controller to hide its navigation bar and toolbar.

Default: false


# hideShadow

Availability
3.2.0
9.2.0
hideShadow :Boolean

Set this to true to hide the shadow image of the navigation bar.

This property is only honored if a valid value is specified for the barImage property.

Default: false


# hidesSearchBarWhenScrolling

Availability
8.1.0
9.2.0
hidesSearchBarWhenScrolling :Boolean

A Boolean value indicating whether the integrated search bar is hidden when scrolling any underlying content.

When the value of this property is true, the search bar is visible only when the scroll position equals the top of your content view. When the user scrolls down, the search bar collapses into the navigation bar. Scrolling back to the top reveals the search bar again. When the value of this property is false, the search bar remains regardless of the current scroll position. You must set showSearchBarInNavBar or showSearchBarInNavBar property for this property to have any effect.

Default: true


# homeIndicatorAutoHidden

Availability
7.3.0
9.2.0
homeIndicatorAutoHidden :Boolean

Boolean value indicating whether the system is allowed to hide the visual indicator for returning to the Home screen.

Set this value true, if you want the system to determine when to hide the indicator. Set this value false, if you want the indicator shown at all times. The system takes your preference into account, but setting true is no guarantee that the indicator will be hidden.

Default: false


# horizontalMotionEffect

Availability
7.3.0
9.2.0
horizontalMotionEffect :MinMaxOptions

Adds a horizontal parallax effect to the view

Note that the parallax effect only happens by tilting the device so results can not be seen on Simulator. To clear all motion effects, use the <Titanium.UI.clearMotionEffects> method.


# horizontalWrap

Availability
2.1.0
2.1.0
9.2.0
horizontalWrap :Boolean

Determines whether the layout has wrapping behavior.

For more information, see the discussion of horizontal layout mode in the description of the layout property.

Default: true


# id

Availability
0.9
0.9
9.2.0
id :String

View's identifier.

The id property of the Ti.UI.View represents the view's identifier. The identifier string does not have to be unique. You can use this property with getViewById method.


# includeOpaqueBars

Availability
3.1.3
9.2.0
includeOpaqueBars :Boolean

Specifies if the edges should extend beyond opaque bars (navigation bar, tab bar, toolbar).

By default edges are only extended to include translucent bars. However if this is set to true, then edges are extended beyond opaque bars as well.

The default behavior assumes that this is false. Must be specified before opening the window.


# keepScreenOn

Availability
0.9
keepScreenOn :Boolean

Determines whether to keep the device screen on.

When true the screen will not power down. Note: enabling this feature will use more power, thereby adversely affecting run time when on battery. For iOS look at idleTimerDisabled.

Default: false


# largeTitleDisplayMode

Availability
6.3.0
9.2.0
largeTitleDisplayMode :Number

The mode to use when displaying the title of the navigation bar.

Automatically use the large out-of-line title based on the state of the previous item in the navigation bar. An item with largeTitleDisplayMode = Ti.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC will show or hide the large title based on the request of the previous navigation item. If the first item pushed is set to Automatic, then it will show the large title if the navigation bar has largeTitleEnabled = true.

Default: Titanium.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC


# largeTitleEnabled

Availability
6.3.0
9.2.0
largeTitleEnabled :Boolean

A Boolean value indicating whether the title should be displayed in a large format.

When set to true, the navigation bar will use a larger out-of-line title view when requested by the current navigation item. To specify when the large out-of-line title view appears, see largeTitleDisplayMode.

Default: false


# layout

Availability
0.9
0.9
9.2.0
layout :String

Specifies how the view positions its children. One of: 'composite', 'vertical', or 'horizontal'.

There are three layout options:

  • composite (or absolute). Default layout. A child view is positioned based on its positioning properties or "pins" (top, bottom, left, right and center). If no positioning properties are specified, the child is centered.

    The child is always sized based on its width and height properties, if these are specified. If the child's height or width is not specified explicitly, it may be calculated implicitly from the positioning properties. For example, if both left and center.x are specified, they can be used to calculate the width of the child control.

    Because the size and position properties can conflict, there is a specific precedence order for the layout properties. For vertical positioning, the precedence order is: height, top, center.y, bottom.

    The following table summarizes the various combinations of properties that can be used for vertical positioning, in order from highest precedence to lowest. (For example, if height, center.y and bottom are all specified, the height and center.y values take precedence.)

    Scenario Behavior
    height & top specified Child positioned top unit from parent's top, using specified height; any center.y and bottom values are ignored.
    height & center.y specified Child positioned with center at center.y, using specified height; any bottom value is ignored.
    height & bottom specified Child positioned bottom units from parent's bottom, using specified height.
    top & center.y specified Child positioned with top edge top units from parent's top and center at center.y. Height is determined implicitly; any bottom value is ignored.
    top & bottom specified Child positioned with top edge top units from parent's top and bottom edge bottom units from parent's bottom. Height is determined implicitly.
    Only top specified Child positioned top units from parent's top, and uses the default height calculation for the view type.
    center.y and bottom specified Child positioned with center at center.y and bottom edge bottom units from parent's bottom. Height is determined implicitly.
    Only center.y specified Child positioned with center at center.y, and uses the default height calculation for the view type.
    Only bottom specified Child positioned with bottom edge bottom units from parent's bottom, and uses the default height calculation for the view type.
    height, top, center.y, and bottom unspecified Child entered vertically in the parent and uses the default height calculation for the child view type.

    Horizontal positioning works like vertical positioning, except that the precedence is width, left, center.x, right.

    For complete details on composite layout rules, see Transitioning to the New UI Layout System in the Titanium Mobile Guides.

  • vertical. Children are laid out vertically from top to bottom. The first child is laid out top units from its parent's bounding box. Each subsequent child is laid out below the previous child. The space between children is equal to the upper child's bottom value plus the lower child's top value.

    Each child is positioned horizontally as in the composite layout mode.

  • horizontal. Horizontal layouts have different behavior depending on whether wrapping is enabled. Wrapping is enabled by default (the horizontalWrap property is true).

    With wrapping behavior, the children are laid out horizontally from left to right, in rows. If a child requires more horizontal space than exists in the current row, it is wrapped to a new row. The height of each row is equal to the maximum height of the children in that row.

    Wrapping behavior is available on iOS and Android. When the horizontalWrap property is set to true, the first row is placed at the top of the parent view, and successive rows are placed below the first row. Each child is positioned vertically within its row somewhat like composite layout mode. In particular:

    • If neither top or bottom is specified, the child is centered in the row.
    • If either top or bottom is specified, the child is aligned to either the top or bottom of the row, with the specified amount of padding.
    • If both top and bottom is specified for a given child, the properties are both treated as padding.

    If the horizontalWrap property is false, the behavior is more equivalent to a vertical layout. Children are laid or horizontally from left to right in a single row. The left and right properties are used as padding between the children, and the top and bottom properties are used to position the children vertically.

    Defaults to Composite layout.


# left

Availability
0.9
0.9
9.2.0
left :Number | String

Window's left position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# leftNavButton

Availability
0.9
9.2.0