Android系统UI显示图层控制方法
2017-08-24 14:30
429 查看
做系统层开发,往往会遇到UI显示图层的一些设置,比如一些界面可以直接被其他界面遮挡,有些界面只能被部分界面遮挡,甚至有些界面需要置顶不被任何界面遮挡;每个界面就是一个Window(窗口),是Window就受WindowManager管理,WindowManager中存在对应的LayoutParams(布局属性),通过设置这些属性可以控制Window的类型,Window的类型中自然就包含其显示图层的控制。
说到这儿我还想谈谈自己对Window的理解,顾名思义它就是一个窗口,这个窗口里面可以包含一些布局,布局中又可以包含一些View控件,整个组成一个可以展示出来供人交互的界面。Android的界面显示是一个三维空间,x,y轴控制需要展示的界面的大小,z轴控制界面显示的图层,这就存在界面显示优先级的说法了。
下面简单的介绍下Window的优先级的设置方法:
adb shell进去执行以下指令可以看到Window所在layer:
dumpsys -l :列出所有可以查看的类型
dumpsys window :列出所有正在运行的window相关参数,Surface: shown=true layer=161000 alpha=1.0 rect=(0.0,0.0) 1920.0 x 1.0参数有图层的大小
dumpsys SurfaceFlinger :界面显示的层叠关系会必现的比较直观
说到这儿我还想谈谈自己对Window的理解,顾名思义它就是一个窗口,这个窗口里面可以包含一些布局,布局中又可以包含一些View控件,整个组成一个可以展示出来供人交互的界面。Android的界面显示是一个三维空间,x,y轴控制需要展示的界面的大小,z轴控制界面显示的图层,这就存在界面显示优先级的说法了。
下面简单的介绍下Window的优先级的设置方法:
private Window mWindow; mWindow = getWindow(); mWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG); // 各种参数的优先级级别请参考下面Android源码
adb shell进去执行以下指令可以看到Window所在layer:
dumpsys -l :列出所有可以查看的类型
dumpsys window :列出所有正在运行的window相关参数,Surface: shown=true layer=161000 alpha=1.0 rect=(0.0,0.0) 1920.0 x 1.0参数有图层的大小
dumpsys SurfaceFlinger :界面显示的层叠关系会必现的比较直观
/** * 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; /** * End of types of application windows. */ public static final int LAST_APPLICATION_WINDOW = 99; /** * 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 */ public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; /** * End of types of sub-windows. */ public static final int LAST_SUB_WINDOW = 1999; /** * Start of system-specific window types. These are not normally * created by applications. */ public static final int FIRST_SYSTEM_WINDOW = 2000; /** * Window type: the status bar. There can be only one status bar * window; it is placed at the top of the screen, and all other * windows are shifted down so they are below it. * In multiuser systems shows on all users' windows. */ public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; /** * Window type: the search bar. There can be only one search bar * window; it is placed at the top of the screen. * In multiuser systems shows on all users' windows. */ public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; /** * Window type: phone. These are non-application windows providing * user interaction with the phone (in particular incoming calls). * These windows are normally placed above all applications, but behind * the status bar. * In multiuser systems shows on all users' windows. */ public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; /** * Window type: system window, such as low power alert. These windows * are always on top of application windows. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; /** * Window type: keyguard window. * In multiuser systems shows on all users' windows. */ public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; /** * Window type: transient notifications. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; /** * Window type: system overlay windows, which need to be displayed * on top of everything else. These windows must not take input * focus, or they will interfere with the keyguard. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; /** * Window type: priority phone UI, which needs to be displayed even if * the keyguard is active. These windows must not take input * focus, or they will interfere with the keyguard. * In multiuser systems shows on all users' windows. */ public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; /** * Window type: panel that slides out from the status bar * In multiuser systems shows on all users' windows. */ public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; /** * Window type: dialogs that the keyguard shows * In multiuser systems shows on all users' windows. */ public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; /** * Window type: internal system error windows, appear on top of * everything they can. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; /** * Window type: internal input methods windows, which appear above * the normal UI. Application windows may be resized or panned to keep * the input focus visible while this window is displayed. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; /** * Window type: internal input methods dialog windows, which appear above * the current input method window. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_INPUT_METHOD_DIALOG= FIRST b279 _SYSTEM_WINDOW+12; /** * Window type: wallpaper window, placed behind any window that wants * to sit on top of the wallpaper. * In multiuser systems shows only on the owning user's window. */ public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; /** * Window type: panel that slides out from over the status bar * In multiuser systems shows on all users' windows. */ public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; /** * Window type: secure system overlay windows, which need to be displayed * on top of everything else. These windows must not take input * focus, or they will interfere with the keyguard. * * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the * system itself is allowed to create these overlays. Applications cannot * obtain permission to create secure system overlays. * * In multiuser systems shows only on the owning user's window. * @hide */ public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; /** * Window type: the drag-and-drop pseudowindow. There is only one * drag layer (at most), and it is placed on top of all other windows. * In multiuser systems shows only on the owning user's window. * @hide */ public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; /** * Window type: panel that slides out from under the status bar * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; /** * Window type: (mouse) pointer * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; /** * Window type: Navigation bar (when distinct from status bar) * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; /** * Window type: The volume level overlay/dialog shown when the user * changes the system volume. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; /** * Window type: The boot progress dialog, goes on top of everything * in the world. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; /** * Window type: Fake window to consume touch events when the navigation * bar is hidden. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22; /** * Window type: Dreams (screen saver) window, just above keyguard. * In multiuser systems shows only on the owning user's window. * @hide */ public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; /** * Window type: Navigation bar panel (when navigation bar is distinct from status bar) * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; /** * Window type: Behind the universe of the real windows. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25; /** * Window type: Display overlay window. Used to simulate secondary display devices. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; /** * Window type: Magnification overlay window. Used to highlight the magnified * portion of a display when accessibility magnification is enabled. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; /** * Window type: Recents. Same layer as {@link #TYPE_SYSTEM_DIALOG} but only appears on * one user's screen. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_RECENTS_OVERLAY = FIRST_SYSTEM_WINDOW+28; /** * Window type: keyguard scrim window. Shows if keyguard needs to be restarted. * In multiuser systems shows on all users' windows. * @hide */ public static final int TYPE_KEYGUARD_SCRIM = FIRST_SYSTEM_WINDOW+29; /** * Window type: Window for Presentation on top of private * virtual display. */ public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; /** * End of types of system windows. */ public static final int LAST_SYSTEM_WINDOW = 2999;
相关文章推荐
- Android动态显示系统时间,附获得当前年月日星期时分秒方法,一步到位
- 控制图层是否显示的方法
- Android图形显示系统——下层显示4:图层合成下(硬件合成器)
- 如何控制android系统中NavigationBar 的显示与隐藏
- Android中的自定义Adapter(继承自BaseAdapter)——与系统Adapter的调用方法一致——含ViewHolder显示效率的优化
- android 状态栏 导航栏隐藏显示控制方法及效果示例
- Android中两种不同的方法实现实时更新时间,是显示时间和系统时间同步
- android系统方法裁剪图片 华为手机显示为圆
- android系统方法裁剪图片部分手机显示为圆形
- Android图形显示系统——下层显示4:图层合成上(合成原理与3D合成)
- Android开发中调用系统相册上传图片到服务器OPPO等部分手机上出现短暂的显示桌面问题的解决方法
- Android中的自定义Adapter(继承自BaseAdapter)——与系统Adapter的调用方法一致——含ViewHolder显示效率的优化
- Android基础系列-----------GUI系统之Android的UI显示概述
- Android中系统默认输入法设置的方法(输入法的显示和隐藏)
- MapGis对图层显示的控制另一方法
- Android图形显示系统——下层显示4:图层合成下(硬件合成器)
- qt编写的android程序在android系统中运行,中文显示乱码的解决方法
- Android拍照保存在系统相册不显示的问题解决方法
- 【Android 开发】:UI控件之显示图片控件 ImageView 的使用方法
- Android图形显示系统——下层显示4:图层合成上(合成原理与3D合成)