// 关键代码Window window = dialog.getWindow();if (window != null) {window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);window.getDecorView().setPadding(0, 0, 0, 0);window.getDecorView().setBackgroundColor(Color.WHITE);WindowManager.LayoutParams layoutParams = window.getAttributes();layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {// 延伸显示区域到刘海WindowManager.LayoutParams lp = window.getAttributes();lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;window.setAttributes(lp);// 设置页面全屏显示final View decorView = window.getDecorView();decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);}window.setAttributes(layoutParams);}
如果觉得《dialog 刘海屏 水滴屏 全面屏 全屏显示》对你有帮助,请点赞、收藏,并留下你的观点哦!