ZOFTINO.COM

Android Multi Window Display Concepts & Configuration

Android users can view more than one app at the same time with new multi-window display feature introduced in Android 7.0, API level 24. With this feature, two apps can be displayed side by side or one above the other in the same window by splitting the screen.

When device is in portrait mode meaning device is being used vertically, two apps which support multi-window display are displayed one above the other (top to bottom).

android multi window display one above the other

Whereas when the device is in landscape mode meaning device is being used horizontally, two apps are displayed side by side (left to right).

android multi window display side by side

The behavior of your app when user tries to view your app along with other app in multi window display mode can be configured. You can configure multi window display behavior for your app for example you restrict your app to be displayed only full screen more.

How to Enter into Multi Window Mode

First of all, apps which you want to view on the screen at same time by displaying them in multi window mode should support multi window feature. Meaning, only apps which are multi-window enabled can be displayed in split screen mode.

There are two ways users can enter into multi window mode. User can enter into multi window display mode by long pressing overview button, the button which helps you view all opened apps. On long pressing overview button, the current activity is put in multi window mode and overview screen is shown so that user can choose second app to display in multi window mode.

Second way of entering into multi window display mode is by long pressing activity title of one of the recent activities on over view screen and then dragging the selected app to the top area where system displays message saying drag here to use split screen.

Configure App for Multi Window Display Mode

You can configure your app to make it support multi window display mode and control size and layout.

To enable or disable multi window display mode, you need to set android:resizeableActivity attribute of activity or application element in manifest file to true or false. If attribute android:resizeableActivity is set to true, multi window feature is enabled. The default value of android:resizeableActivity is true.

If you set root activity’s android:resizeableActivity attribute in a task stack to true, all activities in the stack support multi window feature.

You can configure layout size and location behavior in multi window mode, using manifest’s layout element. Layout element attributes to control size and location are android:minHeight, android:minWidth, android:defaultHeight, android:defaultWidth and android:gravity.

<activity android:name=".NavigationDrawerActivity" android:resizeableActivity="true">
    <layout android:defaultHeight="400dp"
        android:defaultWidth="500dp"
        android:gravity="bottom"
        android:minHeight="450dp"
        android:minWidth="300dp"></layout></activity>

In activity, method isInMultiWindowMode() can be used to find out whether activity is in full screen mode or in multi window display mode and update UI or other behavior which suits the display mode.

There is a callback method in activity related to multi window display mode. That is onMultiWindowModeChanged() method which gets called when there is a change in display mode and it can be used to inject behavior on mode changes.

Launching Activity in Multi Window Mode Using Intent

You can start an activity in multi window mode by using intent flag FLAG_ACTIVITY_LAUNCH_ADJACENT. If device is in split screen mode, the new activity will be placed next to the activity which launched it; otherwise it will have no effect.

And also you need to use FLAG_ACTIVITY_LAUNCH_ADJACENT flag with FLAG_ACTIVITY_NEW_TASK to get the expected behavior.