WindowManager.LayoutParams.TYPE_SYSTEM_ALERT : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; lp.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW; 1 2 3 ...
步骤1:创建一个新的 WindowManager.LayoutParams 对象 // 创建一个新的 WindowManager.LayoutParams 对象WindowManager.LayoutParamsparams=newWindowManager.LayoutParams(); 1. 2. 步骤2:设置 LayoutParams 的 Type 为 TYPE_SYSTEM_ALERT // 设置 LayoutParams 的 Type 为 TYPE_SYSTEM_ALERT,确保窗口可以显示在最顶层param...
windowParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; }else{ windowParams.type = LayoutParams.TYPE_TOAST; } windowParams.format = PixelFormat.RGBA_8888; windowParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE; ...
3.WindowManager.LayoutParams(int _type, int _flags) 4.WindowManager.LayoutParams(int _type, int _flags, int _format) 5.WindowManager.LayoutParams(int w, int h, int _type, int _flags, int _format) 6.WindowManager.LayoutParams(int w, int h, int xpos, int ypos, int _type, int _flags,...
在上一篇《#SystemUI(一)基于Android9.0SystemUI的启动与定制化 》中,了解了SystemUI的启动流程,同时也知道流程的最后主要是StatusBar通过WindowManager的addView()将view装载在系统的界面上,在此之前都要利用WindowManager.LayoutParams来设置该window的显示,那么在源码里出现的WindowManager是什么?WindowManager.LayoutParams的...
FIRST_SYSTEM_WINDOW …….. LAST_SYSTEM_WINDOW FIRST_SYSTEM_WINDOW = 2000; TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW +3; ...
WindowManager.LayoutParamsparams=newWindowManager.LayoutParams();if(Build.VERSION.SDK_INT>=25){params.type=params.TYPE_SYSTEM_ALERT;}elseif(Build.VERSION.SDK_INT>=19){params.type=params.TYPE_TOAST;}else{params.type=params.TYPE_PHONE;} 而且android系统限制同一时间只能有一个弹窗存在,否则抛出异常。
val dialog = Dialog(application)dialog.setContentView(textView)if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {dialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY)}else{dialog.window?.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT)}dialog.show() ...
type = LayoutParams.TYPE_SYSTEM_ALERT; mLp.format = PixelFormat.RGBA_8888; mLp.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE; mLp.gravity = Gravity.LEFT | Gravity.TOP; mLp.width = WindowManager.LayoutParams.WRAP_CONTENT; mLp.height = WindowManager.LayoutPara...
1. 申请悬浮窗权限,或者使用层级较低的TYPE_PHONE悬浮窗。 if (Build.VERSION.SDK_INT > 24) { wmParams.type = WindowManager.LayoutParams.TYPE_PHONE; } else { wmParams.type = WindowManager.LayoutParams.TYPE_TOAST; } 2. 系统8.0以上使用SYSTEM_ALERT_WINDOW 权限的应用无法再使用以下窗口类型来在其他应...