在开启了导航栏的项目上,想要全屏显示一个悬浮窗口,比如:手势唤醒动画窗口,如果没有设置窗口的布局参数
导航栏会显示出来,影响窗口的全屏显示
所以添加窗口的布局参数是关键,按以下设置是有效的:
private WindowManager.LayoutParams mLp;
private WindowManager mWm = (WindowManager) getSystemService(this.WINDOW_SERVICE);
设置布局参数,红色部分是关键参数
mLp = new WindowManager.LayoutParams();
mLp.format = PixelFormat.RGBA_8888;
mLp.type = WindowManager.LayoutParams.TYPE_DRAG;
mLp.gravity = Gravity.LEFT | Gravity.TOP;
mLp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
mLp.x = 0;
mLp.y = 0;
Display display = mWm.getDefaultDisplay();
Point p = new Point();
display.getRealSize(p);
mLp.width = p.x;
mLp.height = p.y;
mLp.setTitle("GestureAnim");
添加并显示窗口
mWm.addView(mLayout, mLp);