第一种方法 利用 xml 配置全局 设置
<!-- values-29/themes.xml: -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<!-- Optional, but recommended for full edge-to-edge rendering -->
<item name="android:statusBarColor">@android:color/transparent</item>
这种方法 需要 在 values 文件夹下面的 主题xml中 添加 才会有效
第二种 方法 是 利用 java代码来进行配置‘’
//获取window 系统窗口
Window window = getWindow();
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP){
//清除屏幕
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//设置满屏
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
具体操作 参考 确保与手势导航兼容 | Android 开发者 | Android Developers (google.cn)