diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 83e58bf4..a8d4379e 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -225,13 +225,22 @@ public class CordovaActivity extends AppCompatActivity { boolean isStatusBarVisible = statusBarView.getVisibility() != View.GONE; int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ? bars.top : 0; - int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0; int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0; int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0; + Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()); + // When in fullscreen mode, we ignore bottom system insets (like the navigation bar) + // to allow the WebView to span the entire screen and avoid being pushed up. + int bottom = isFullScreen ? 0 : canEdgeToEdge ? imeInsets.bottom : Math.max(bars.bottom, imeInsets.bottom); + FrameLayout.LayoutParams webViewParams = (FrameLayout.LayoutParams) webView.getLayoutParams(); - webViewParams.setMargins(left, top, right, bottom); - webView.setLayoutParams(webViewParams); + // Only update layout margins if the values have actually changed. + // This prevents redundant layout passes and potential infinite layout loops + if (webViewParams.leftMargin != left || webViewParams.topMargin != top + || webViewParams.rightMargin != right || webViewParams.bottomMargin != bottom) { + webViewParams.setMargins(left, top, right, bottom); + webView.setLayoutParams(webViewParams); + } FrameLayout.LayoutParams statusBarParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT,