Просмотр исходного кода

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.
Anthony 1 месяц назад
Родитель
Сommit
13b0a36ae9
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

+ 3 - 5
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");