Skip to content

fix(statusbar): give statusBarView initial layout params so it cannot cover the WebView - #2009

Open
cyril23 wants to merge 1 commit into
apache:masterfrom
LogicsSoftwareGmbH:fix-statusbar-view-initial-params
Open

fix(statusbar): give statusBarView initial layout params so it cannot cover the WebView#2009
cyril23 wants to merge 1 commit into
apache:masterfrom
LogicsSoftwareGmbH:fix-statusbar-view-initial-params

Conversation

@cyril23

@cyril23 cyril23 commented Aug 30, 2026

Copy link
Copy Markdown

Platforms affected

Android

Motivation and Context

Fixes #1947.

CordovaActivity.createViews adds statusBarView to rootLayout without LayoutParams and only sizes it inside rootLayout's OnApplyWindowInsetsListener, so the view starts with FrameLayout's default MATCH_PARENT x MATCH_PARENT. On API 21–27 the listener never runs once SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN is cleared (e.g. by cordova-plugin-statusbar's Android side for StatusBarOverlaysWebView=false): WindowCompat.setDecorFitsSystemWindows(window, false) is only emulated through that flag below API 30, and without it the decor's fitsSystemWindows content root consumes the insets before they reach rootLayout (on API 28/29 the dispatch happens to continue because of the display-cutout part of WindowInsets.isConsumed(), on API 30+ Window.setDecorFitsSystemWindows(false) makes the content root pass them through). The view then covers the whole WebView, painted in the status-bar color by SystemBarPlugin — the app shows only a solid color after the splash screen. Full analysis with a dumpsys view hierarchy in #1947.

Description

Give statusBarView initial LayoutParams(MATCH_PARENT, 0, Gravity.TOP). When insets arrive, the listener resizes the view exactly as before; when they never arrive, the view stays 0 px high instead of covering the WebView.

Testing

Samsung Galaxy S7, Android 8.0.0 (API 26), Chrome WebView 138, cordova-plugin-statusbar 4.0.0 with StatusBarOverlaysWebView=false, app sets StatusBarBackgroundColor=#2A95D2 (AndroidEdgeToEdge default). Before: full-screen colored view over the WebView (dumpsys activity top: View{… 0,0-1080,1848} above SystemWebView{… 0,0-1080,1848}). After: app visible, status bar as expected (View{… 0,0-1080,0}).

before (top of the screen) after
Galaxy S7 unpatched: status bar, then solid StatusBarBackgroundColor Galaxy S7 with the fix: app header rendered

The change was applied to cordova-android 15.1.0 via an after_prepare hook in our app for these tests (our app itself now avoids the trigger by not installing the statusbar plugin's Android side). npm run lint and the 337 JS specs pass; java-unit-tests was not run locally (no Android SDK on the machine used for the PR), the Java change was verified with the device builds above.

Checklist

  • I've run the tests to see all new and existing tests pass (lint + JS specs; Java tests: see Testing)
  • I added automated test coverage as appropriate for this change (no Java view tests exist for this code path)
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android)) — repo convention fix(statusbar): used
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary (none needed)

… cover the WebView

When the window insets never reach the Cordova root layout (observed on a
Samsung Galaxy S7 / Android 8.0 where the decor consumes them), the
OnApplyWindowInsetsListener that sizes statusBarView never runs. The view
then keeps FrameLayout's default MATCH_PARENT x MATCH_PARENT params and,
painted in StatusBarBackgroundColor, covers the whole WebView: the app shows
nothing but a solid color after the splash screen.

Start with a height of 0 instead; the listener still resizes the view when
insets arrive.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.20%. Comparing base (a637442) to head (c13742b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2009   +/-   ##
=======================================
  Coverage   63.20%   63.20%           
=======================================
  Files          24       24           
  Lines        4922     4922           
=======================================
  Hits         3111     3111           
  Misses       1811     1811           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Statusbar overlays complete app when setting StatusBarOverlaysWebView to false on Android 7/8 using cordova-plugin-statusbar

3 participants