fix: webview loses scrollability and creates empty bottom space (#1924)

Co-authored-by: Gabriel Moré Maia <gabriel.maia@cresol.com.br>
Co-authored-by: Manuel Beck <manuelbeck87@outlook.de>
This commit is contained in:
Gabriel Moré Maia
2026-05-19 11:20:41 -03:00
committed by GitHub
parent c636f8bbe4
commit b91144c0d4
@@ -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,