mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
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:
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,
|
||||
|
||||
Reference in New Issue
Block a user