From b91144c0d4d19663bbd94ec4db0aea25da24c2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Mor=C3=A9=20Maia?= Date: Tue, 19 May 2026 11:20:41 -0300 Subject: [PATCH] fix: webview loses scrollability and creates empty bottom space (#1924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gabriel Moré Maia Co-authored-by: Manuel Beck --- .../src/org/apache/cordova/CordovaActivity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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,