admin管理员组文章数量:1334920
When I use EdgeToEdge.enable(this);
in the onCreate()
method of my activity, it allows my activity to occupy the entire screen of the phone, including the space of the status bar and the navigation bar.
However, as soon as I switch to full screen, the layout shrinks, the status bar area turns black, and I can no longer display anything in that area.
I’ve tried several solutions to resolve this issue, including:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if (controller != null) {
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
}
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
But nothing works. In all cases, my layout loses the upper part of the screen.
This happens on my phone, a Pixel 8 Pro running Android 15, but I know it’s not a phone bug because some apps like WhatsApp and Google Photos can display photos in full screen without a status bar. And this is exactly what I’m trying to replicate.
Do you have any idea?
When I use EdgeToEdge.enable(this);
in the onCreate()
method of my activity, it allows my activity to occupy the entire screen of the phone, including the space of the status bar and the navigation bar.
However, as soon as I switch to full screen, the layout shrinks, the status bar area turns black, and I can no longer display anything in that area.
I’ve tried several solutions to resolve this issue, including:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if (controller != null) {
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
}
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
But nothing works. In all cases, my layout loses the upper part of the screen.
This happens on my phone, a Pixel 8 Pro running Android 15, but I know it’s not a phone bug because some apps like WhatsApp and Google Photos can display photos in full screen without a status bar. And this is exactly what I’m trying to replicate.
Do you have any idea?
Share Improve this question asked Nov 20, 2024 at 19:32 KazuyaKazuya 654 bronze badges1 Answer
Reset to default 0After almost two weeks of struggle, I figured out that I just had to do this during the activity initialization:
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
this.getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
本文标签: androidAdroid StudioFullscreen with full layoutStack Overflow
版权声明:本文标题:android - Adroid Studio - Fullscreen with full layout - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742334487a2455352.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论