【发布时间】:2021-04-09 20:05:45
【问题描述】:
我试图在我的 splash 上隐藏(状态栏和导航栏) screen ,但它变成了黑色状态,如下图所示。
我的风格代码:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@color/color_navigation_bar</item>
</style>
还有我的 java 代码:
private void hideSystemUI() {
Window window = this.getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // API 30
window.setDecorFitsSystemWindows(false);
} else {
// window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
我也在尝试使用这段代码,但仍然是黑色的:
this.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
谁能帮帮我?
【问题讨论】:
标签: android android-studio uinavigationbar fullscreen