Android 系统用户界面模式更改后如何更改屏幕覆盖(全屏、隐藏导航)?
我创建覆盖:Android 系统用户界面模式更改后如何更改屏幕覆盖(全屏、隐藏导航)?,android,overlay,fullscreen,Android,Overlay,Fullscreen,我创建覆盖: mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); /*The parent view (actually the root view) the
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
/*The parent view (actually the root view) the will be added in front of all the windows on the screen*/
mOverlayView = (RelativeLayout) inflater.inflate(R.layout.overlay_control, null);
mWindowManager.getDefaultDisplay().getSize(size);
mWindowSize = new Size(size.x, size.y);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
WindowManager.LayoutParams.FLAG_FULLSCREEN,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
mWindowManager.addView(mOverlayView, params);
如果系统UI可见性发生变化,我需要移动覆盖。有可能在视图中检测它(),但在覆盖中不起作用。因此,我只需要回调来检测设备的模式是否改变。我找到了方法: 在安卓系统中,有
onSystemMiviabilityChangeListener
,但如果没有具有match\u parent
宽度或高度值的视图,它就不起作用
因此,我创建了这样的覆盖,使其高度为1px,宽度为match\u parent
width,并向其添加onsystemivilitychangesetener