自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
支援多視窗模式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在 Android 7.0 以上版本中,裝置可透過多視窗同時顯示多個應用程式。Android 支援三種多視窗設定:
-
Freeform 可讓使用者動態調整活動窗格的大小,並在畫面上顯示兩個以上的應用程式。
-
分割畫面是預設的多視窗實作方式,可提供兩個活動窗格,讓使用者放置應用程式。
-
子母畫面 (PIP) 可讓 Android 裝置在使用者與其他應用程式互動時,在小視窗中播放影片內容。
實作
Android 7.0 以上版本預設會啟用多視窗支援功能。如要停用這項功能,請在裝置的 config.xml 檔案中將 config_supportsMultiWindow
標記設為 false
。
在所有低 RAM 裝置 (宣告 ActivityManager.isLowRam()
的裝置) 上,多重視窗功能預設為停用。低 RAM 裝置會忽略 config_supportsMultiWindow
標記的值。
使用 config_supportsMultiWindow
旗標啟用多視窗模式後,裝置製造商可以允許任意形式的視窗。這個模式最適合用於平板電腦等大型裝置。
如要支援自由格式模式,請在 /android/frameworks/base/core/java/android/content/pm/PackageManager.java
中啟用 PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT
系統功能,並在 config.xml.
中將 config_freeformWindowManagement
設為 true
<bool name="config_freeformWindowManagement">true</bool>
在 Android 16 中,原始設備製造商 (OEM) 可使用「Enable desktop windowing」,在裝置上支援自由形式多視窗設定。
啟用電腦視窗化模式
如要啟用裝置的電腦視窗功能,請按照下列步驟操作:
-
確認裝置支援自由格式視窗功能。
-
在
config.xml
中,將設定疊加標記 config_isDesktopModeSupported
標記設為 true
:
<bool name="config_isDesktopModeSupported">true</bool>
-
如要在裝置的內部螢幕上啟用自由形式視窗功能,請將設定覆蓋層標記
config_canInternalDisplayHostDesktops
設為 true
。config.xml
如果 config_isDesktopModeSupported
為 false
,系統會忽略這個標記:
<bool name="config_canInternalDisplayHostDesktops">true</bool>
啟用工作限制
請按照下列步驟設定桌面視窗模式支援的最大工作數量:
-
啟用電腦視窗功能。
-
將
config.xml
中的設定重疊標記 config_maxDesktopWindowingActiveTasks
設為支援的工作數量上限。如要支援無限數量的任務,請將旗標設為 0
的預設值:
<bool name="config_maxDesktopWindowingActiveTasks">4</integer>
分割畫面
多視窗的預設體驗為分割畫面模式,在該模式下,系統 UI 會在裝置的正/橫向中間分割。視裝置方向而定,使用者可以將分隔線從左到右或從上到下拖曳,調整視窗大小。
啟用分割畫面後,裝置製造商可以選擇啟用自由形式或 PIP。
Android 8.0 以上版本會在使用者輕觸「Home」時壓縮啟動器,藉此改善分割畫面。如要進一步瞭解實作方式,請參閱「分割畫面互動」。
子母畫面
使用 config_supportsMultiWindow
標記啟用多視窗模式後,裝置製造商就能支援子母畫面,讓使用者在瀏覽其他活動時觀看影片。雖然這項功能適用於 Android TV 裝置,但其他類型的裝置也可能支援這項功能。
如要支援 PIP,請在 /android/frameworks/base/core/java/android/content/pm/PackageManager.java
中啟用 PackageManager#FEATURE_PICTURE_IN_PICTURE
系統功能。
如要進一步瞭解搭載 Android 8.0 以上版本的裝置的 PIP 實作方式,請參閱「子母畫面」頁面。
系統 UI
根據多視窗開發人員說明文件支援所有標準系統使用者介面。
應用程式
如要支援預先載入應用程式的多視窗模式,請參閱 Android 開發人員說明文件。
驗證
如要驗證多視窗實作方式,請執行相關 CTS 測試,並按照多視窗測試操作說明操作。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Support multi-window\n\nIn Android 7.0 and higher, devices can display multiple apps\nsimultaneously using multi-window. Android supports three\nmulti-window configurations:\n\n- **Freeform** allows users to dynamically resize the activity panes and have more than two apps visible on their screen.\n- **Split-screen** is the default multi-window implementation, which provides two activity panes where users can place apps.\n- **Picture-in-picture (PIP)** allows Android devices to play video content in a small window while the user interacts with other apps.\n\nImplementation\n--------------\n\n\nMulti-window support is enabled by default in Android 7.0 and higher.\nTo disable it, set the `config_supportsMultiWindow` flag to\n`false` in your device's\n[config.xml](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/res/res/values/config.xml) file.\n\n\nMulti-window is disabled by default on all low-RAM devices (devices that\ndeclare `ActivityManager.isLowRam()`). Low-RAM devices\nignore the value of the `config_supportsMultiWindow` flag.\n\n### Freeform\n\n\nAfter enabling multi-window mode with the\n`config_supportsMultiWindow` flag, device manufacturers can\nallow freeform windowing. This mode is most useful on larger devices,\nsuch as tablets.\n\n\nTo support freeform mode, enable the\n`PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT` system\nfeature in\n[/android/frameworks/base/core/java/android/content/pm/PackageManager.java](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/java/android/content/pm/PackageManager.java)\nand set `config_freeformWindowManagement` to `true` in\n[config.xml](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/res/res/values/config.xml)`.` \n\n```\n \u003cbool name=\"config_freeformWindowManagement\"\u003etrue\u003c/bool\u003e\n \n```\n\n\nIn Android 16, OEMs can support desktop windowing on their device for a\nfreeform multi-window configuration using [Enable desktop windowing](/docs/core/display/multi-window#enable-desktop-windowing).\n\n#### Enable desktop windowing\n\n\nFollow these steps to enable desktop windowing on your device:\n\n- Make sure your device supports [freeform](/docs/core/display/multi-window#freeform) windowing.\n- Set the config overlay flag `config_isDesktopModeSupported` flag to `true` in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/res/res/values/config.xml): \n\n ```\n \u003cbool name=\"config_isDesktopModeSupported\"\u003etrue\u003c/bool\u003e\n \n ```\n- To enable freeform windowing on the internal display of your device, set the config overlay flag `config_canInternalDisplayHostDesktops` to `true` in `config.xml`. This flag is ignored if `config_isDesktopModeSupported` is `false`: \n\n ```\n \u003cbool name=\"config_canInternalDisplayHostDesktops\"\u003etrue\u003c/bool\u003e\n \n ```\n\n##### Enable task limits\n\n\nFollow these steps to configure the maximum number of tasks supported in desktop\nwindowing:\n\n1. [Enable desktop windowing](#enable-desktop-windowing).\n2. Set the config overlay flag `config_maxDesktopWindowingActiveTasks` in [`config.xml`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/res/res/values/config.xml) to the maximum number of supported tasks. To support an unlimited number of tasks, set the flag to the default value of `0`: \n\n ```\n \u003cbool name=\"config_maxDesktopWindowingActiveTasks\"\u003e4\u003c/integer\u003e\n \n ```\n\n### Split-screen\n\n\nMulti-window's default experience is split-screen mode, where the System\nUI is divided down the middle of the device in portrait or landscape.\nUsers can resize the window by dragging the dividing line side to side\nor top to bottom, depending on the device orientation.\n\n\nAfter enabling split-screen, device manufacturers can choose to enable\nfreeform or PIP.\n\n\nAndroid 8.0 and higher improves split-screen by compressing the launcher\nwhen the user taps **Home** . For implementation details, see\n[Split-screen interactions](/docs/core/display/split-screen).\n\n### Picture-in-picture\n\n\nAfter enabling multi-window mode with the\n`config_supportsMultiWindow` flag, device manufacturers can\nsupport\n[picture-in-picture](https://developer.android.com/training/tv/playback/picture-in-picture.html), which allows users to watch\nvideo while browsing other activities. While this feature is targeted at\nAndroid Television devices, other device types may support this feature.\n\n\nTo support PIP, enable the\n`PackageManager#FEATURE_PICTURE_IN_PICTURE` system feature in\n[/android/frameworks/base/core/java/android/content/pm/PackageManager.java](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/java/android/content/pm/PackageManager.java).\n\n\nFor more PIP implementation details for devices running Android 8.0 and\nhigher,see the [Picture-in-picture](/docs/core/display/pip)\npage.\n\n### System UI\n\n\nSupport all standard System UIs according to\n[Multi-window developer documentation](https://developer.android.com/guide/topics/ui/multi-window.html#testing).\n\n### Apps\n\n\nTo support multi-window mode for preloaded apps, consult the\n[Android developer documentation](https://developer.android.com/guide/topics/ui/multi-window.html).\n\nValidation\n----------\n\n\nTo validate your implementation of multi-window, run the related CTS\ntests and follow the\n[testing instructions for multi-window](https://developer.android.com/guide/topics/ui/multi-window.html#testing).\n\n| Android version | CTS test |\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 7.0 | [/platform/cts/hostsidetests/services/activitymanager/src/android/server/cts](https://android.googlesource.com/platform/cts/+/refs/heads/nougat-cts-release/hostsidetests/services/activitymanager/src/android/server/cts) |\n| 8.0 | [/platform/cts/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts](https://android.googlesource.com/platform/cts/+/refs/heads/oreo-cts-release/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts) |\n| 9.0 | [/platform/cts/tests/framework/base/activitymanager/src/android/server/am](https://android.googlesource.com/platform/cts/+/refs/heads/pie-cts-release/tests/framework/base/activitymanager/src/android/server/am) |\n| 10.0 and above | [/platform/cts/tests/framework/base/windowmanager/src/android/server/wm](https://android.googlesource.com/platform/cts/+/refs/heads/android16-release/tests/framework/base/windowmanager/src/android/server/wm) |"]]