赞
踩
- 应用 Window(ApplicationWindow: 对应一个 Acitivity)
- 子 Window (SubWindow:不能单独存在,需要依附在特定的父 Window 中,比如常见的一些 Dialog 就是一个子 Window)
- 系统 Window (SystemWindow:需要声明权限才能创建的 Window,比如 Toast 和系统状态栏都是系统 Window)
Window 是分层的,每个 Window 都有对应的 z-ordered,层级大的会覆盖在层级小的 Window 上面,这和 HTML 中的 z-index 概念是完全一致的。
在三种 Window 中,每一种Window的层级范围也是不同的,如下:
应用Window 1~99
子Window 1000~1999
系统Window 2000~2999
这些层级范围对应着 WindowManager.LayoutParams 的 type 参数,如果想要 Window 位于所有 Window 的最顶层,那么采用较大的层级即可,很显然系统 Window 的层级是最大的,当我们采用系统层级时,需要声明权限。
- package android.view;
- public interface WindowManager
- /**
- * Start of window types that represent normal application windows.
- */
- public static final int FIRST_APPLICATION_WINDOW = 1;
-
- /**
- * Window type: an application window that serves as the "base" window
- * of the overall application; all other application windows will
- * appear on top of it.
- * In multiuser systems shows only on the owning user's window.
- */
- public static final int TYPE_BASE_APPLICATION = 1;
-
- /**
- * Window type: a normal application window. The {@link #token} must be
- * an Activity token identifying who the window belongs to.
- * In multiuser systems shows only on the owning user's window.
- */
- public static final int TYPE_APPLICATION = 2;
-
- /**
- * Window type: special application window that is displayed while the
- * application is starting. Not for use by applications themselves;
- * this is used by the system to display something until the
- * application can show its own windows.
- * In multiuser systems shows on all users' windows.
- */
- public static final int TYPE_APPLICATION_STARTING = 3;
-
- /**
- * Window type: a variation on TYPE_APPLICATION that ensures the window
- * manager will wait for this window to be drawn before the app is shown.
- * In multiuser systems shows only on the owning user's window.
- */
- public static final int TYPE_DRAWN_APPLICATION = 4;
-
- /**
- * End of types of application windows.
- */
- public static final int LAST_APPLICATION_WINDOW = 99;

- package android.view;
- public interface WindowManager
- /**
- * Start of types of sub-windows. The {@link #token} of these windows
- * must be set to the window they are attached to. These types of
- * windows are kept next to their attached window in Z-order, and their
- * coordinate space is relative to their attached window.
- */
- public static final int FIRST_SUB_WINDOW = 1000;
-
- /**
- * Window type: a panel on top of an application window. These windows
- * appear on top of their attached window.
- */
- public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
-
- /**
- * Window type: window for showing media (such as video). These windows
- * are displayed behind their attached window.
- */
- public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
-
- /**
- * Window type: a sub-panel on top of an application window. These
- * windows are displayed on top their attached window and any
- * {@link #TYPE_APPLICATION_PANEL} panels.
- */
- public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
-
- /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
- * of the window happens as that of a top-level window, <em>not</em>
- * as a child of its container.
- */
- public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
-
- /**
- * Window type: window for showing overlays on top of media windows.
- * These windows are displayed between TYPE_APPLICATION_MEDIA and the
- * application window. They should be translucent to be useful. This
- * is a big ugly hack so:
- * @hide
- */
- @UnsupportedAppUsage
- public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4;
-
- /**
- * Window type: a above sub-panel on top of an application window and it's
- * sub-panel windows. These windows are displayed on top of their attached window
- * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
- * @hide
- */
- public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
-
- /**
- * End of types of sub-windows.
- */
- public static final in

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。