Design your apps for foldables

Foldable device partially folded, showing the front of the device.

Android 10 (API level 29) adds more support for foldable devices.

Unfolding a device to provide a larger screen can have a positive impact on usability:

  • A larger screen usually means a more immersive experience
  • With multi-window mode, users can multi-task

Folding and unfolding a device can change the size, density, or aspect ratio of the display. This is not a new problem in Android development; it's also a concern in use cases that don't involve foldable devices, for example:

  • Switching between portrait and landscape orientation on phones and tablets
  • Resizing Android apps on Chrome OS in desktop mode
  • Using devices with multiple displays

This page describes best practices to make sure your app works well with foldable form factors.

You may also want to read the Android 10 summary of changes related to support for foldables.

App continuity

When running on a foldable device, an app can transition from one screen to another automatically. After the transition, the app should resume in the same state and location, and the current task should continue seamlessly.

Animation of a foldable device folding outward.

Since the system triggers a configuration change during a fold or unfold transition, apps should save the UI state and support configuration changes gracefully.

Note: Foldable devices can fold in many ways, such as inward (with the display folding into the interior of the device) or outward (with the display wrapping around the device):

Make your app resizable

Ensure that your app works in multi-window mode and with dynamic display resizing. To provide maximum compatibility with whatever form factors and environments your app might encounter (like foldables, desktop mode, or free-form windows), set resizeableActivity=true in the <application> or <activity> section of the project manifest file. Test your app's behavior in split-screen mode or with a foldable emulator.

If your app sets resizeableActivity=false, the app will not support multi-window mode. The system may still resize your app or put it in multi-window mode, but compatibility is implemented by applying the same configuration to all the components in the app, including all activities and services. In some cases, major changes (like a display size change) might restart the process rather than change the configuration.

For example, the activity below has set resizableActivity=false along with a maxAspectRatio. When the device is unfolded, the activity configuration, size, and aspect ratio are maintained by putting the app in compatibility mode.

Foldable device showing an application that only partially fills
          the unfolded display area.

If you set resizeableActivity=false to disable multi-window mode but still want to support app continuity, add the following metadata to the <application> element of your manifest file:

<meta-data
    android:name="android.supports_size_changes" android:value="true" />

If supports_size_changes is true and the user folds or unfolds the device, the activity applies any changed configurations in a way that supports changes in window sizes.

If you do not set resizeableActivity (or you set it to true) the system assumes the app fully supports multi-window mode and is resizable.

Note that some OEMs might implement a feature that adds a small restart icon on the screen each time the activity's display area changes. This gives the user the chance to restart the activity in the new configuration.

Foldable Modes

Foldable devices have either a fold in the display or a hinge that separates two portions (typically halves) of the display. Devices with a hinge might have the ability to span content behind the hinge; for example, the Microsoft Surface Duo in its spanned mode. Some devices may be able to be placed in a half-folded configuration or other posture such as Samsung's Flex Mode.

The Jetpack Window Manager library gives you a device-agnostic way of reacting to device modes, configuration changes, and display features. See the blog post, Support new form factors with the new Jetpack Window Manager library, to learn more.

Postures

Foldable devices can support the postures shown below, which correspond to the FoldingFeature state constants STATE_FLAT and STATE_HALF_OPENED. The FoldingFeature class is part of the Jetpack Window Manager library. FoldingFeature identifies devices that have a hinge or a display fold. FoldingFeature implements the DisplayFeature interface (which can be implemented by new display types as the device ecosystem continues to grow).

Vertically foldable device fully open.
STATE_FLAT
Vertically foldable device opened halfway in tabletop (or
              laptop) posture.
STATE_HALF_OPENED
(Laptop or tabletop posture)

Use the FoldingFeature class to retrieve device postures. You can check directly for the following states:

Or you can use the following properties that abstract the state of a folding device:

Use these properties to recognize different postures like laptop, tabletop, or book mode (where the hinge is vertical):

private fun isTableTopPosture(foldFeature: FoldingFeature) =
        foldFeature.isSeparating &&
        foldFeature.orientation == FoldingFeature.ORIENTATION_HORIZONTAL

private fun isBookPosture(foldFeature: FoldingFeature) =
        foldFeature.isSeparating &&
        foldFeature.orientation == FoldingFeature.ORIENTATION_VERTICAL

You can be notified of any changes in the FoldingFeature state by registering a callback with the registerLayoutChangeCallback method of the WindowManager class. To stop receiving updates, remove the callback using unregisterLayoutChangeCallback.

The callback receives data in a WindowLayoutInfo object which contains a list of the window's display features. Use the displayFeatures property to access the information:

class LayoutStateChangeCallback : Consumer<WindowLayoutInfo> {
    override fun accept(newLayoutInfo: WindowLayoutInfo) {
        // Check newLayoutInfo.displayFeatures to see if the
        // feature list includes a FoldingFeature, then check
        // the feature's data.
    }
}

Hinge angle

Starting with Android 11, apps running on devices with hinged screens can determine the angle of the hinge if the device has a sensor that provides a TYPE_HINGE_ANGLE value and reports a SensorEvent that provides the number of degrees of the hinge angle. You can use these measurements to perform granular animations as the user manipulates the device.

Even though some kinds of apps (such as launchers and wallpapers) may find it useful to know the exact hinge angle, most apps should use the Jetpack Window Manager library to retrieve the device posture because responding to the posture is more reliable due to the many different device configurations currently in the market (with more coming in the future).

Testing

To get your app ready for foldables, you should test how your app reacts to:

  • Configuration changes
  • Multi-window mode and multi-resume
  • Resizing and new display aspect ratios

Foldable emulators

The Android Open Source Project (AOSP) includes a variety of device emulators that simulate the functionality of foldable and rollable devices.

Android Studio's Android Virtual Device (AVD) Manager enables you to easily test your app using foldable and rollable device emulators.

Animation of a foldable device opening and closing in a device
          emulator.

Foldable device emulator.

Multi-display

The Force desktop developer option enables you to turn on system decoration support on all secondary displays. Force desktop mode also displays a mouse pointer on the secondary displays instead of on the default display. When used with the Enable Freeform windows developer option, Force desktop simulates a desktop experience with multi-window mode and the ability to resize windows.

You can work with multiple displays using a simulated display or, if you have a device that supports HDMI or DisplayPort over USB-C, using a wired connection.

Phone showing a dialog box that enables selection of various types
          of simulated secondary displays.

Simulated display.