请选择 进入手机版 | 继续访问电脑版

[Android] Android WindowManger的层级分析详解

[复制链接]
查看52 | 回复5 | 2021-9-14 06:15:12 | 显示全部楼层 |阅读模式
目次

一. Window 分类

  1. <ul>
  2. <li>应用 Window<strong>(</strong>ApplicationWindow: 对应一个 Acitivity<strong>)
  3. </strong></li>
  4. <li>子 Window    <strong>(</strong>SubWindow:不能单独存在,需要依附在特定的父 Window 中,比如常见的一些 Dialog 就是一个子 Window<strong>)
  5. </strong></li>
  6. <li>系统 Window <strong>(</strong>SystemWindow:需要声明权限才能创建的 Window,比如 Toast 和系统状态栏都是系统 Window<strong>)</strong></li>
  7. </ul>
复制代码

二. Window层级

Window 是分层的,每个 Window 都有对应的 z-ordered,层级大的会覆盖在层级小的 Window 上面,这和 HTML 中的 z-index 概念是完全划一 的。

在三种 Window 中,每一种Window的层级范围也是不同的,如下:

  1. 应用Window    1~99
  2. 子Window        1000~1999
  3. 系统Window    2000~2999
复制代码

这些层级范围对应着 WindowManager.LayoutParams type 参数,假如 想要 Window 位于全部 Window 的最顶层,那么采用较大的层级即可,很显然体系 Window 的层级是最大的,当我们采用体系 层级时,必要 声明权限。

(1)应用程序窗口:

  1. package android.view;
  2. public interface WindowManager
  3. /**
  4. * Start of window types that represent normal application windows.
  5. */
  6. public static final int FIRST_APPLICATION_WINDOW = 1;
  7. /**
  8. * Window type: an application window that serves as the "base" window
  9. * of the overall application; all other application windows will
  10. * appear on top of it.
  11. * In multiuser systems shows only on the owning user's window.
  12. */
  13. public static final int TYPE_BASE_APPLICATION = 1;
  14. /**
  15. * Window type: a normal application window. The {@link #token} must be
  16. * an Activity token identifying who the window belongs to.
  17. * In multiuser systems shows only on the owning user's window.
  18. */
  19. public static final int TYPE_APPLICATION = 2;
  20. /**
  21. * Window type: special application window that is displayed while the
  22. * application is starting. Not for use by applications themselves;
  23. * this is used by the system to display something until the
  24. * application can show its own windows.
  25. * In multiuser systems shows on all users' windows.
  26. */
  27. public static final int TYPE_APPLICATION_STARTING = 3;
  28. /**
  29. * Window type: a variation on TYPE_APPLICATION that ensures the window
  30. * manager will wait for this window to be drawn before the app is shown.
  31. * In multiuser systems shows only on the owning user's window.
  32. */
  33. public static final int TYPE_DRAWN_APPLICATION = 4;
  34. /**
  35. * End of types of application windows.
  36. */
  37. public static final int LAST_APPLICATION_WINDOW = 99;
复制代码

(2)子窗口:

  1. package android.view;
  2. public interface WindowManager
  3. /**
  4. * Start of types of sub-windows. The {@link #token} of these windows
  5. * must be set to the window they are attached to. These types of
  6. * windows are kept next to their attached window in Z-order, and their
  7. * coordinate space is relative to their attached window.
  8. */
  9. public static final int FIRST_SUB_WINDOW = 1000;
  10. /**
  11. * Window type: a panel on top of an application window. These windows
  12. * appear on top of their attached window.
  13. */
  14. public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
  15. /**
  16. * Window type: window for showing media (such as video). These windows
  17. * are displayed behind their attached window.
  18. */
  19. public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
  20. /**
  21. * Window type: a sub-panel on top of an application window. These
  22. * windows are displayed on top their attached window and any
  23. * {@link #TYPE_APPLICATION_PANEL} panels.
  24. */
  25. public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
  26. /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
  27. * of the window happens as that of a top-level window, <em>not</em>
  28. * as a child of its container.
  29. */
  30. public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
  31. /**
  32. * Window type: window for showing overlays on top of media windows.
  33. * These windows are displayed between TYPE_APPLICATION_MEDIA and the
  34. * application window. They should be translucent to be useful. This
  35. * is a big ugly hack so:
  36. * @hide
  37. */
  38. @UnsupportedAppUsage
  39. public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4;
  40. /**
  41. * Window type: a above sub-panel on top of an application window and it's
  42. * sub-panel windows. These windows are displayed on top of their attached window
  43. * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
  44. * @hide
  45. */
  46. public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
  47. /**
  48. * End of types of sub-windows.
  49. */
  50. public static final int LAST_SUB_WINDOW = 1999;
复制代码

(3)体系 窗口:

  1. package android.view;
  2. public interface WindowManager
  3. /**
  4. * Start of system-specific window types. These are not normally
  5. * created by applications.
  6. */
  7. public static final int FIRST_SYSTEM_WINDOW = 2000;
  8. /**
  9. * Window type: the status bar. There can be only one status bar
  10. * window; it is placed at the top of the screen, and all other
  11. * windows are shifted down so they are below it.
  12. * In multiuser systems shows on all users' windows.
  13. */
  14. public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
  15. /**
  16. * Window type: the search bar. There can be only one search bar
  17. * window; it is placed at the top of the screen.
  18. * In multiuser systems shows on all users' windows.
  19. */
  20. public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
  21. /**
  22. * Window type: phone. These are non-application windows providing
  23. * user interaction with the phone (in particular incoming calls).
  24. * These windows are normally placed above all applications, but behind
  25. * the status bar.
  26. * In multiuser systems shows on all users' windows.
  27. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  28. */
  29. @Deprecated
  30. public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
  31. /**
  32. * Window type: system window, such as low power alert. These windows
  33. * are always on top of application windows.
  34. * In multiuser systems shows only on the owning user's window.
  35. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  36. */
  37. @Deprecated
  38. public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
  39. /**
  40. * Window type: keyguard window.
  41. * In multiuser systems shows on all users' windows.
  42. * @removed
  43. */
  44. public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
  45. /**
  46. * Window type: transient notifications.
  47. * In multiuser systems shows only on the owning user's window.
  48. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  49. */
  50. @Deprecated
  51. public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
  52. /**
  53. * Window type: system overlay windows, which need to be displayed
  54. * on top of everything else. These windows must not take input
  55. * focus, or they will interfere with the keyguard.
  56. * In multiuser systems shows only on the owning user's window.
  57. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  58. */
  59. @Deprecated
  60. public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
  61. /**
  62. * Window type: priority phone UI, which needs to be displayed even if
  63. * the keyguard is active. These windows must not take input
  64. * focus, or they will interfere with the keyguard.
  65. * In multiuser systems shows on all users' windows.
  66. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  67. */
  68. @Deprecated
  69. public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
  70. /**
  71. * Window type: panel that slides out from the status bar
  72. * In multiuser systems shows on all users' windows.
  73. */
  74. public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
  75. /**
  76. * Window type: dialogs that the keyguard shows
  77. * In multiuser systems shows on all users' windows.
  78. */
  79. public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
  80. /**
  81. * Window type: internal system error windows, appear on top of
  82. * everything they can.
  83. * In multiuser systems shows only on the owning user's window.
  84. * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
  85. */
  86. @Deprecated
  87. public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
  88. /**
  89. * Window type: internal input methods windows, which appear above
  90. * the normal UI. Application windows may be resized or panned to keep
  91. * the input focus visible while this window is displayed.
  92. * In multiuser systems shows only on the owning user's window.
  93. */
  94. public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
  95. /**
  96. * Window type: internal input methods dialog windows, which appear above
  97. * the current input method window.
  98. * In multiuser systems shows only on the owning user's window.
  99. */
  100. public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
  101. /**
  102. * Window type: wallpaper window, placed behind any window that wants
  103. * to sit on top of the wallpaper.
  104. * In multiuser systems shows only on the owning user's window.
  105. */
  106. public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
  107. /**
  108. * Window type: panel that slides out from over the status bar
  109. * In multiuser systems shows on all users' windows.
  110. */
  111. public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
  112. /**
  113. * Window type: secure system overlay windows, which need to be displayed
  114. * on top of everything else. These windows must not take input
  115. * focus, or they will interfere with the keyguard.
  116. *
  117. * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
  118. * system itself is allowed to create these overlays. Applications cannot
  119. * obtain permission to create secure system overlays.
  120. *
  121. * In multiuser systems shows only on the owning user's window.
  122. * @hide
  123. */
  124. @UnsupportedAppUsage
  125. public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
  126. /**
  127. * Window type: the drag-and-drop pseudowindow. There is only one
  128. * drag layer (at most), and it is placed on top of all other windows.
  129. * In multiuser systems shows only on the owning user's window.
  130. * @hide
  131. */
  132. public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
  133. /**
  134. * Window type: panel that slides out from over the status bar
  135. * In multiuser systems shows on all users' windows. These windows
  136. * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL}
  137. * windows.
  138. * @hide
  139. */
  140. public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
  141. /**
  142. * Window type: (mouse) pointer
  143. * In multiuser systems shows on all users' windows.
  144. * @hide
  145. */
  146. public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
  147. /**
  148. * Window type: Navigation bar (when distinct from status bar)
  149. * In multiuser systems shows on all users' windows.
  150. * @hide
  151. */
  152. public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
  153. /**
  154. * Window type: The volume level overlay/dialog shown when the user
  155. * changes the system volume.
  156. * In multiuser systems shows on all users' windows.
  157. * @hide
  158. */
  159. public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
  160. /**
  161. * Window type: The boot progress dialog, goes on top of everything
  162. * in the world.
  163. * In multiuser systems shows on all users' windows.
  164. * @hide
  165. */
  166. public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
  167. /**
  168. * Window type to consume input events when the systemUI bars are hidden.
  169. * In multiuser systems shows on all users' windows.
  170. * @hide
  171. */
  172. public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
  173. /**
  174. * Window type: Dreams (screen saver) window, just above keyguard.
  175. * In multiuser systems shows only on the owning user's window.
  176. * @hide
  177. */
  178. public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
  179. /**
  180. * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
  181. * In multiuser systems shows on all users' windows.
  182. * @hide
  183. */
  184. public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
  185. /**
  186. * Window type: Display overlay window. Used to simulate secondary display devices.
  187. * In multiuser systems shows on all users' windows.
  188. * @hide
  189. */
  190. @UnsupportedAppUsage
  191. public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
  192. /**
  193. * Window type: Magnification overlay window. Used to highlight the magnified
  194. * portion of a display when accessibility magnification is enabled.
  195. * In multiuser systems shows on all users' windows.
  196. * @hide
  197. */
  198. public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
  199. /**
  200. * Window type: Window for Presentation on top of private
  201. * virtual display.
  202. */
  203. public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
  204. /**
  205. * Window type: Windows in the voice interaction layer.
  206. * @hide
  207. */
  208. public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
  209. /**
  210. * Window type: Windows that are overlaid <em>only</em> by a connected {@link
  211. * android.accessibilityservice.AccessibilityService} for interception of
  212. * user interactions without changing the windows an accessibility service
  213. * can introspect. In particular, an accessibility service can introspect
  214. * only windows that a sighted user can interact with which is they can touch
  215. * these windows or can type into these windows. For example, if there
  216. * is a full screen accessibility overlay that is touchable, the windows
  217. * below it will be introspectable by an accessibility service even though
  218. * they are covered by a touchable window.
  219. */
  220. public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
  221. /**
  222. * Window type: Starting window for voice interaction layer.
  223. * @hide
  224. */
  225. public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
  226. /**
  227. * Window for displaying a handle used for resizing docked stacks. This window is owned
  228. * by the system process.
  229. * @hide
  230. */
  231. public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
  232. /**
  233. * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used
  234. * by Quick Settings Tiles.
  235. * @hide
  236. */
  237. public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
  238. /**
  239. * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is
  240. * reserved for screenshot region selection. These windows must not take input focus.
  241. * @hide
  242. */
  243. public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
  244. /**
  245. * Window type: Window for Presentation on an external display.
  246. * @see android.app.Presentation
  247. * @hide
  248. */
  249. public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37;
  250. /**
  251. * Window type: Application overlay windows are displayed above all activity windows
  252. * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW})
  253. * but below critical system windows like the status bar or IME.
  254. * <p>
  255. * The system may change the position, size, or visibility of these windows at anytime
  256. * to reduce visual clutter to the user and also manage resources.
  257. * <p>
  258. * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission.
  259. * <p>
  260. * The system will adjust the importance of processes with this window type to reduce the
  261. * chance of the low-memory-killer killing them.
  262. * <p>
  263. * In multi-user systems shows only on the owning user's screen.
  264. */
  265. public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38;
  266. /**
  267. * End of types of system windows.
  268. */
  269. public static final int LAST_SYSTEM_WINDOW = 2999;
复制代码
  1.  窗口显示顺序:
  2. Type 值越大层级越高,Type 值大的覆盖 Type 值小的,这只是一般规律。
复制代码

(三)怎样 真正查看 Window 的优先级

  1. /frameworks/base/services/core/java/com/android/server/policy/WindowManagerPolicy.java
  2. default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) {
  3. if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
  4. return APPLICATION_LAYER;
  5. }
  6. switch (type) {
  7. case TYPE_WALLPAPER:
  8. // wallpaper is at the bottom, though the window manager may move it.
  9. return 1;
  10. case TYPE_PRESENTATION:
  11. case TYPE_PRIVATE_PRESENTATION:
  12. return APPLICATION_LAYER;
  13. case TYPE_DOCK_DIVIDER:
  14. return APPLICATION_LAYER;
  15. case TYPE_QS_DIALOG:
  16. return APPLICATION_LAYER;
  17. case TYPE_PHONE:
  18. return 3;
  19. case TYPE_SEARCH_BAR:
  20. case TYPE_VOICE_INTERACTION_STARTING:
  21. return 4;
  22. case TYPE_VOICE_INTERACTION:
  23. // voice interaction layer is almost immediately above apps.
  24. return 5;
  25. case TYPE_INPUT_CONSUMER:
  26. return 6;
  27. case TYPE_SYSTEM_DIALOG:
  28. return 7;
  29. case TYPE_TOAST:
  30. // toasts and the plugged-in battery thing
  31. return 8;
  32. case TYPE_PRIORITY_PHONE:
  33. // SIM errors and unlock. Not sure if this really should be in a high layer.
  34. return 9;
  35. case TYPE_SYSTEM_ALERT:
  36. // like the ANR / app crashed dialogs
  37. return canAddInternalSystemWindow ? 11 : 10;
  38. case TYPE_APPLICATION_OVERLAY:
  39. return 12;
  40. case TYPE_DREAM:
  41. // used for Dreams (screensavers with TYPE_DREAM windows)
  42. return 13;
  43. case TYPE_INPUT_METHOD:
  44. // on-screen keyboards and other such input method user interfaces go here.
  45. return 14;
  46. case TYPE_INPUT_METHOD_DIALOG:
  47. // on-screen keyboards and other such input method user interfaces go here.
  48. return 15;
  49. case TYPE_STATUS_BAR:
  50. return 17;
  51. case TYPE_STATUS_BAR_PANEL:
  52. return 18;
  53. case TYPE_STATUS_BAR_SUB_PANEL:
  54. return 19;
  55. case TYPE_KEYGUARD_DIALOG:
  56. return 20;
  57. case TYPE_VOLUME_OVERLAY:
  58. // the on-screen volume indicator and controller shown when the user
  59. // changes the device volume
  60. return 21;
  61. case TYPE_SYSTEM_OVERLAY:
  62. // the on-screen volume indicator and controller shown when the user
  63. // changes the device volume
  64. return canAddInternalSystemWindow ? 22 : 11;
  65. case TYPE_NAVIGATION_BAR:
  66. // the navigation bar, if available, shows atop most things
  67. return 23;
  68. case TYPE_NAVIGATION_BAR_PANEL:
  69. // some panels (e.g. search) need to show on top of the navigation bar
  70. return 24;
  71. case TYPE_SCREENSHOT:
  72. // screenshot selection layer shouldn't go above system error, but it should cover
  73. // navigation bars at the very least.
  74. return 25;
  75. case TYPE_SYSTEM_ERROR:
  76. // system-level error dialogs
  77. return canAddInternalSystemWindow ? 26 : 10;
  78. case TYPE_MAGNIFICATION_OVERLAY:
  79. // used to highlight the magnified portion of a display
  80. return 27;
  81. case TYPE_DISPLAY_OVERLAY:
  82. // used to simulate secondary display devices
  83. return 28;
  84. case TYPE_DRAG:
  85. // the drag layer: input for drag-and-drop is associated with this window,
  86. // which sits above all other focusable windows
  87. return 29;
  88. case TYPE_ACCESSIBILITY_OVERLAY:
  89. // overlay put by accessibility services to intercept user interaction
  90. return 30;
  91. case TYPE_SECURE_SYSTEM_OVERLAY:
  92. return 31;
  93. case TYPE_BOOT_PROGRESS:
  94. return 32;
  95. case TYPE_POINTER:
  96. // the (mouse) pointer layer
  97. return 33;
  98. default:
  99. Slog.e("WindowManager", "Unknown window type: " + type);
  100. return APPLICATION_LAYER;
  101. }
  102. }
复制代码
  1.  以上返回的是除 Application 外的 Window 的层级,在开发系统应用时可以选择一种开发自己的 Window.
复制代码

(四) 层级高低具体 分析(对比Toast以及软键盘)

  1. 低于toast--->盖不住toast
  2. 低于软键盘--->盖不住软键盘
  3. 依附Activity使用--->is your activity running?
  4. public static int getWindowType(int num) {
  5. switch (num) {
  6. case 1:
  7. return WindowManager.LayoutParams.TYPE_PHONE;//低于toast 低于软键盘
  8. case 2:
  9. return WindowManager.LayoutParams.TYPE_SEARCH_BAR;//低于toast 低于软键盘
  10. case 3:
  11. return WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;//低于toast 低于软键盘
  12. case 4:
  13. return WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;//高于toast 低于软键盘
  14. case 5:
  15. return WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;//高于toast 低于软键盘
  16. case 6:
  17. return WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;//高于toast 盖住键盘
  18. case 7:
  19. return WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;//高于toast 低于软键盘
  20. case 8:
  21. return WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;//高于toast 低于软键盘
  22. case 9:
  23. return WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;//高于toast 高于软键盘
  24. case 10:
  25. return WindowManager.LayoutParams.TYPE_STATUS_BAR;//高于toast 高于软键盘(键盘会把透明view顶起)
  26. case 11:
  27. return WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;//高于toast 高于软键盘(键盘会把透明view顶起)
  28. case 12:
  29. return WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;//低于下级页面
  30. case 13:
  31. return WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;//is your activity running?
  32. case 14:
  33. return WindowManager.LayoutParams.TYPE_BASE_APPLICATION;// is your activity running?
  34. case 15:
  35. return WindowManager.LayoutParams.TYPE_APPLICATION;// is your activity running?
  36. case 16:
  37. return WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;// is your activity running?
  38. case 17:
  39. return WindowManager.LayoutParams.TYPE_DRAWN_APPLICATION;// is your activity running?
  40. case 18:
  41. return WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;// is your activity running?
  42. case 19:
  43. return WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;// is your activity running?
  44. case 20:
  45. return WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;// is your activity running?
  46. case 21:
  47. return WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;// is your activity running?
  48. case 22:
  49. return WindowManager.LayoutParams.TYPE_WALLPAPER;// is your activity running?
  50. case 23:
  51. return WindowManager.LayoutParams.TYPE_TOAST;// is your activity running?
  52. case 24:
  53. return WindowManager.LayoutParams.TYPE_INPUT_METHOD;//is your activity running?
  54. case 25:
  55. return WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;//permission denied for window type 2030
  56. default:
  57. return 0;
  58. }
  59. }
复制代码

(五)怎样 定制体系 层级

  1. 改变层级关系需要改写 getWindowLayerFromTypeLw 的 switch 顺序结构和返回值
  2. 如果需要更改一些 Window 的行为,需要修改
  3. /frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
复制代码

到此这篇关于Android WindowManger的层级分析详解的文章就先容 到这了,更多干系 Android WindowManger的层级分析内容请搜刮 脚本之家从前 的文章或继续欣赏 下面的干系 文章渴望 大家以后多多支持脚本之家!


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

avatar 大黄瓜xxxl | 2021-9-27 20:10:18 | 显示全部楼层
今天皮痒了?
回复

使用道具 举报

avatar 宝贝不哭不t | 2021-10-3 15:24:46 | 显示全部楼层
强,我和我的小伙伴们都惊呆了!
回复

使用道具 举报

avatar 天一教育培训寐 | 2021-10-5 17:42:52 | 显示全部楼层
看帖回帖一条路!
回复

使用道具 举报

论坛的帖子越来越有深度了!
回复

使用道具 举报

回帖也有有水平的!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则