文章目录
前言
Android窗口模式类型介绍。
一、Android窗口模式
Android12 窗口模式有
WINDOWING_MODE_FULLSCREEN(全屏)、
WINDOWING_MODE_PINNED(画中画)、
WINDOWING_MODE_SPLIT_SCREEN_PRIMARY(分屏中的主屏)、
WINDOWING_MODE_SPLIT_SCREEN_SECONDARY(分屏中的副屏)、
WINDOWING_MODE_FREEFORM(自由窗口)、
WINDOWING_MODE_MULTI_WINDOW(多窗口)。
/** Windowing mode is currently not defined. */
public static final int WINDOWING_MODE_UNDEFINED = 0;
/** Occupies the full area of the screen or the parent container. */
public static final int WINDOWING_MODE_FULLSCREEN = 1;
/** Always on-top (always visible). of other siblings in its parent container. */
public static final int WINDOWING_MODE_PINNED = 2;
/** The primary container driving the screen to be in split-screen mode. */
// TODO: Remove once split-screen is migrated to wm-shell.
public static final int WINDOWING_MODE_SPLIT_SCREEN_PRIMARY = 3;
/**
* The containers adjacent to the {@link #WINDOWING_MODE_SPLIT_SCREEN_PRIMARY} container in
* split-screen mode.
* NOTE: Containers launched with the windowing mode with APIs like
* {@link ActivityOptions#setLaunchWindowingMode(int)} will be launched in
* {@link #WINDOWING_MODE_FULLSCREEN} if the display isn't currently in split-screen windowing
* mode
*/
// TODO: Remove once split-screen is migrated to wm-shell.
public static final int WINDOWING_MODE_SPLIT_SCREEN_SECONDARY = 4;
/** Can be freely resized within its parent container. */
// TODO: Remove once freeform is migrated to wm-shell.
public static final int WINDOWING_MODE_FREEFORM = 5;
/** Generic multi-window with no presentation attribution from the window manager. */
public static final int WINDOWING_MODE_MULTI_WINDOW = 6;
1. WINDOWING_MODE_FULLSCREEN(全屏)
全屏窗口模式是最常见的窗口模式之一。在这种模式下,运行应用的窗口占据整个屏幕,而且一般用于运行单个应用程序,以全屏窗口呈现内容。
2. WINDOWING_MODE_PINNED(画中画)
允许 Android 设备在用户与其他应用互动时在小窗口中播放视频内容。
画中画窗口模式是一种特殊的多窗口模式,最常用于视频播放。
当某个 Activity 处于 PIP 模式时,它会处于暂停状态,但仍应继续显示内容。
要指定您的 Activity 可以使用 PIP 模式,请在清单中将 android:supportsPictureInPicture 设置为 true。
3. WINDOWING_MODE_SPLIT_SCREEN_PRIMARY(分屏中的主屏)
分屏模式,并排显示两个App,primary和secondary分别代表了左右或上下半屏的App所处的窗口模式。
在Android14上被移除了。
4. WINDOWING_MODE_SPLIT_SCREEN_SECONDARY(分屏中的副屏)
分屏模式,并排显示两个App,primary和secondary分别代表了左右或上下半屏的App所处的窗口模式。
在Android14上被移除了。
5. WINDOWING_MODE_FREEFORM(自由窗口)
允许用户动态调整 activity 窗格大小,在屏幕上自由移动,并在屏幕上显示两个以上的应用。
PC版默认启用的桌面模式就是自由窗口的实现。
6. WINDOWING_MODE_MULTI_WINDOW(多窗口)
Android13的分屏模式对应的窗口模式,Android12应该没有用到的地方。