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.
This commit is contained in:
Anthony
2026-08-02 17:27:57 +01:00
committed by Sam Lantinga
parent a4340f1187
commit 13b0a36ae9

View File

@@ -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");