Screen orientation

Detecting screen orientation changes with the mobile device.

Detecting screen orientation changes

Mobile apps can adapt to the device orientation, when switching between portrait and landscape mode.

Screen orientation changes can be detected with the windowresized predefined action:
ON ACTION windowresized
   ...

For more details, see Adapting to viewport changes.

Controlling screen orientation on GMA / Android

Use the allowedOrientations Window style attribute, to control screen orientation options on Android devices:
<Style name="Window.main">
  <StyleAttribute name="allowedOrientations" value="portrait_reverse" />
</Style>

For the complete list of possible values, see Window style attributes.

Controlling screen orientation on GMI / iOS

On iOS devices using GMI, the screen orientation possibilities must be defined in the Info.plist resource file. Keys such as UISupportedInterfaceOrientations must be defined in the file, for example:
<?xml version="1.0" encoding= "UTF-8"?>
<!DOCTYPE plist PUBLIC  "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version= "1.0">
<dict>
        <key>UISupportedInterfaceOrientations</key>
        <array>
                <string>UIInterfaceOrientationPortrait</string>
                <string>UIInterfaceOrientationPortraitUpsideDown</string>
        </array>
        <key>UISupportedInterfaceOrientations~ipad</key>
        <array>
                <string>UIInterfaceOrientationPortrait</string>
                <string>UIInterfaceOrientationPortraitUpsideDown</string>
        </array>
</dict>
</plist>

For more details about Info.plist usage, see the section about defining iOS app properties in Info.plist.