I'm struggling with making an activity fullscreen and I've gotten this so far:
if(Build.VERSION.SDK_INT < 30) {
View decorView = getWindow().getDecorView();
int uiOptions = decorView.getSystemUiVisibility();
int newUiOptions = uiOptions;
newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
newUiOptions |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(newUiOptions);
} else {
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);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
getWindow().getAttributes().layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; }
It works on android 11 but on 10 I'm still getting black navigation and notification bars.