Titanium 3.X

Titanium.UI.Window.orientationModes

Titanium.UI.Window
: Number[]
Array of supported orientation modes, specified using the orientation constants defined in Titanium.UI. ...

Array of supported orientation modes, specified using the orientation constants defined in Titanium.UI.

To restrict this window to a certain set of orientations, specify one or more of the orientation constants LANDSCAPE_LEFT, LANDSCAPE_RIGHT, PORTRAIT, UPSIDE_PORTRAIT.

orientationModes must be set before opening the window.

To determine the current orientation of the window, see Window.orientation. To determine the current orientation of the device, see Gesture.orientation. To be notified when the device's current orientation changes, add a listener for the Titanium.Gesture.orientationchange event.

Android Orientation Modes

On Android, orientationModes only takes effect when specified on a heavyweight window.

On Android, orientation behavior is dependent on the Android SDK level of the device itself. Devices running Android 2.3 and above support "sensor portait mode" and "sensor landscape mode," in these modes, the device is locked into either a portrait or landscape orientation, but can switch between the normal and reverse orientations (for example, between PORTRAIT and UPSIDE_PORTRAIT).

In addition, the definition of portrait or landscape mode can vary based on the physical design of the device. For example, on some devices Titanium.UI.LANDSCAPE_LEFT represents the top of the device being at the 270 degree position but other devices may (based on camera position for example) treat this position as Titanium.UI.LANDSCAPE_RIGHT. In general, applications for Android that need to be aware of orientation should try and limit their orientation logic to handling either portrait or landscape rather than worrying about the reverse modes. This approach will allow the orientation modes to adopt a more natural feel for the specific device.

The following list breaks down the orientation behavior on Android based on the contents of the orientationModes array:

  1. Empty array. Enables orientation to be fully controlled by the device sensor.

  2. Array includes one or both portrait modes and one or both landscape modes. Enables full sensor control (identical to an empty array).

  3. Array contains PORTRAIT and UPSIDE_PORTRAIT. On Android 2.3 and above, enables sensor portrait mode. This means the screen will shift between both portrait modes according to the sensor inside the device.

    On Android versions below 2.3, locks screen orientation in normal portrait mode.

  4. Array contains LANDSCAPE_LEFT and LANDSCAPE_RIGHT. On Android 2.3 and above, enables sensor landscape mode. This means the screen will shift between both landscape modes according to the sensor inside the device.

    On Android versions below 2.3, locks screen orientation in normal landscape mode.

  5. Array contains only PORTRAIT. Locks screen orientation to normal portrait mode.

  6. Array contains only LANDSCAPE_LEFT. Locks screen orientation to normal landscape mode.

  7. Array contains only UPSIDE_PORTRAIT. On Android 2.3 and above, locks screen in reverse portrait mode.

    On Android versions below 2.3, results are undefined.

  8. Array contains only LANDSCAPE_RIGHT. On Android 2.3 and above, locks screen in reverse landscape mode.

    On Android versions below 2.3, results are undefined.

Default: empty array

  • 0.9
  • 0.9
  • 0.9