From 13b0a36ae94c604c3e57a377b994dca142d92599 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 2 Aug 2026 17:27:57 +0100 Subject: [PATCH] Fix edge-to-edge layout for Android 11 and above if setDecorFitsSystemWindows is done too late, then the initial window size won't be the right size. Zeroing the safe zone is nonsense, as it's handled correctly elsewhere. --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index b1dfa9f221..1e5065c563 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -384,6 +384,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh Log.v(TAG, "onCreate()"); super.onCreate(savedInstanceState); + if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) { + getWindow().setDecorFitsSystemWindows(false); + } /* Control activity re-creation */ if (mSDLMainFinished || mActivityCreated) { @@ -1037,7 +1040,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh // Android 15+ (API 35+), where edge-to-edge is enforced for // apps targeting that SDK, so the status/navigation bars // would never hide. Use WindowInsetsController instead. - window.setDecorFitsSystemWindows(false); final WindowInsetsController controller = window.getInsetsController(); if (controller != null) { controller.hide(WindowInsets.Type.systemBars()); @@ -1080,10 +1082,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) { window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; } - if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */ && - Build.VERSION.SDK_INT < 35 /* Android 15 */) { - SDLActivity.onNativeInsetsChanged(0, 0, 0, 0); - } } } else { Log.e(TAG, "error handling message, getContext() returned no Activity");