private void fitNotch() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
boolean isSupport = SPUtils.getBoolean(this, SPUtils.KEY_YSDK_SUPPORT_NOTCH, false);
YSDKApi.setNotchSupport(isSupport);
boolean isAppSupportNotch = SPUtils.getBoolean(this, SPUtils.KEY_APP_IS_SUPPORT_NOTCH, false);
if (isAppSupportNotch) {
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(lp);
// 设置页面全屏显示
final View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
}
适配刘海屏
最新推荐文章于 2024-05-16 16:59:59 发布