Screen orientation

On this page 8

Screen orientation is the rotational state in which a device presents its user interface, most commonly portrait (taller than wide) or landscape (wider than tall). In mobile fundamentals, it describes how the operating system, the motion sensors and each app together decide which edge of the display counts as the top, and how the layout is redrawn when that decision changes.

Orientation looks trivial to users, yet it affects layout, input, media playback, camera capture and app state. On Mobile platforms such as Android and iOS, a rotation can recreate screens, resize windows and shift the keyboard, so developers treat orientation as a configuration change that must be handled deliberately rather than as a cosmetic detail.

How a device detects and applies screen orientation

A device determines screen orientation by reading the accelerometer, often fused with the gyroscope, to find the direction of gravity relative to the display. The sensor framework converts raw acceleration into a device orientation angle, and the window manager maps that angle to one of four screen rotations: 0, 90, 180 or 270 degrees.

The system does not rotate at the first small tilt. It applies hysteresis and a short settling delay, typically a few hundred milliseconds, so the screen does not flicker when a phone is held near 45 degrees. Rotation is also suppressed when the device lies flat on a table, because gravity then gives no reliable horizontal reference.

Once a new rotation is accepted, the window manager checks the user rotation lock, the app’s declared preference and any device policy. Only then does it rotate the display, update the reported screen dimensions and notify the foreground app. The table below summarizes the components involved in this chain.

ComponentRoleTypical input
AccelerometerMeasures the gravity vectorAcceleration on three axes
GyroscopeSmooths fast rotational movementAngular velocity
Window managerChooses and applies the rotationSensor angle, locks, app policy
Rotation lockFreezes the current orientationUser toggle in quick settings
App declarationRestricts allowed orientationsManifest or property list entry
Components that decide the displayed orientation

Orientation values and modes

Operating systems distinguish more states than simply portrait and landscape. Both main modes have a normal and a reverse variant, and apps can request a fixed value, a sensor-driven value or a value that follows the user’s lock. The following table lists the common modes and when each is appropriate.

ModeBehaviorTypical use
PortraitTop edge near the earpieceFeeds, messaging, forms
Reverse portraitDevice turned upside downOften disabled on phones
LandscapeRotated 90 degrees left or rightVideo, games, spreadsheets
Sensor landscapeEither landscape side by sensorGames that allow flipping
Unspecified or full sensorSystem or sensor chooses freelyGeneral-purpose apps
LockedFixed regardless of tiltCamera viewfinders, kiosks
Common orientation modes

On Android, these values are set with the screenOrientation attribute of an activity or changed at runtime with setRequestedOrientation. On iOS and iPadOS, an app lists supported interface orientations in its property list and can narrow them per view controller. In both cases the declared preference is a request, not a guarantee, because the system may override it.

Screen orientation and the app lifecycle

A rotation is a configuration change that can disrupt the running screen. On Android, the default response is to destroy and recreate the activity, so that resources for the new width and height are loaded. Any state that is not saved, such as text in an unsaved field or a scroll position, is lost unless the developer preserves it.

Developers preserve state through saved instance state bundles, lifecycle-aware view models or declarative frameworks that keep state outside the view. iOS does not recreate the view controller by default; instead it calls size transition callbacks and lets Auto Layout recompute constraints. The comparison below shows how the two main platforms behave.

AspectAndroidiOS
Default reactionActivity recreatedView resized in place
State riskHigh without saved stateLower, but layout may break
DeclarationManifest attribute per activitySupported orientations list
Runtime hookConfiguration change callbackSize transition callback
Layout toolsResource qualifiers, ComposeSize classes, Auto Layout
Rotation handling on the two main platforms

Because recreation is expensive, some teams declare that they handle the change themselves. This avoids recreation but transfers full responsibility for re-layout to the app, which is a common source of subtle bugs. Neighboring Terms such as App lifecycle describe the broader sequence of states in more detail.

Large screens, foldables and multi-window

On tablets, foldable phones and desktop-style windowing, orientation alone no longer describes the available space. A window can be landscape on a portrait device when the app runs in split screen, and a foldable can switch from a narrow outer display to a nearly square inner one. Modern guidance therefore favors window size classes over orientation checks.

Recent Android versions increasingly ignore orientation locks on large screens, so a portrait-only app may be shown letterboxed or resized on a tablet. iPadOS likewise expects apps to support all orientations and multitasking sizes. Apps that hard-code portrait assumptions often show stretched layouts, clipped controls or black bars in these environments.

Designing and testing for rotation

Good orientation design starts with deciding whether rotation adds value. Locking orientation is justified for camera capture, certain games and scanning flows, but locking a reading or form app simply because layouts were not designed for landscape harms accessibility, especially for users who mount devices on wheelchairs or stands. Accessibility guidelines such as WCAG 2.1 success criterion 1.3.4 require content not to be restricted to one orientation unless that orientation is essential.

The decision table below maps typical situations to a recommended orientation strategy.

SituationRecommended approachReason
Content feed or readerSupport both orientationsAccessibility and user choice
Full-screen videoAuto-rotate to landscape on playUses the full display width
Camera viewfinderLock UI, rotate icons onlyAvoids jarring preview resets
Fast action gameSensor landscapeAllows either grip side
Large-screen layoutAdapt to window sizeOrientation misleads in split screen
Choosing an orientation strategy

Testing should include rotation during network requests, rotation with the keyboard open, rotation while a dialog is shown and rapid repeated rotations. Automated UI tests can force rotations through emulator or simulator controls, which exposes state loss and memory leaks early.

Common problems and their causes

Most orientation defects come from unpreserved state or rigid layouts. The table lists frequent symptoms, their usual cause and a practical fix.

SymptomLikely causeFix
Form input disappearsState not saved on recreationStore state in a view model
Duplicate network callsRequest restarted after rotationKeep work outside the view
Clipped buttons in landscapeFixed heights in the layoutUse scrollable, flexible layouts
Screen will not rotateRotation lock or app restrictionCheck settings and declarations
Letterboxing on tabletsPortrait-only declarationSupport resizable windows
Typical rotation defects

A related misconception is that device orientation equals screen orientation. A game may read raw device angles for steering while keeping the interface fixed in landscape, so the two values can legitimately differ.

Put simply

Screen orientation is simply which way the picture on your phone is turned. Hold the phone upright and you get a tall view; turn it sideways and the picture turns with it to fill the wider space.

A small motion sensor inside the phone feels which way is down, and the phone uses that to decide. You can stop this with the rotation lock, and some apps choose to stay one way, like a camera or a game. The key idea is that every turn makes the app redraw itself, and a well-built app does that without losing what you were doing.

In practice

A team building a banking app received complaints that users lost a half-completed transfer form when they turned their phones to read a long account number. The Android version recreated the screen on rotation, and the form fields were held only in the view, so every rotation wiped the entered data.

The developers moved the form state into a lifecycle-aware view model, replaced fixed-height containers with a scrollable layout and tested rotation with the keyboard open on phones, a tablet and a foldable. They also removed a portrait-only restriction that had caused letterboxing on tablets.

After the update, the app passed orientation and accessibility review, support tickets about lost transfers stopped, and tablet users received a proper two-column layout in landscape instead of a narrow strip with black bars.