I have a phone with display cut out. And nowadays the most popular phones is with display cut out. But i noticed, when I test a landscape game, it don't support/recognize the phone's display cut out. And it's don't totally fullscreen. https://i.sstatic.net/zSaMo.png
An example, Brawl Stars: https://i.sstatic.net/uwB8c.jpg
Is There anyway to hide/support/recognize the display cut out, in Android Java App?
Thanks, and have a nice day!
According to the official documentation:
Android might not allow the content view to overlap the system bars. To override this behavior and force content to extend into the cutout area, apply any of the following flags to the view visibility via the View.setSystemUiVisibility(int) method:
Also note that setSystemUiVisibility is deprecated in API Level 30 and windowInsetsController can be used instead.
Edit: Try using all these flags:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
//Hide status and navigation bars
int uiOptions;
if (Build.VERSION.SDK_INT < 19) {
uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //Prevent layout resize
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE //when bars are shown
| View.SYSTEM_UI_FLAG_FULLSCREEN //Enable full screen
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //Hides status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; //Hides navigation bar
} else {
uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //Prevent layout resize
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE //when bars are shown
| View.SYSTEM_UI_FLAG_FULLSCREEN //Enable full screen
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //Hides status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //Hides navigation bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; //Immersive ui experience
}
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}
}
These flags will most certainly remove the status bar and the content will be displayed full screen.
Then try messing around with this code by removing each flag and looking at its effects on the screen content. This way, you will understand practically each flag's use.
Finally, read the javadocs for each flag, as they provide many details and will answer almost all your questions about each flag.