fix(statusbar): give statusBarView initial layout params so it cannot cover the WebView - #2009
Open
cyril23 wants to merge 1 commit into
Open
Conversation
… 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.
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
dpogue
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Platforms affected
Android
Motivation and Context
Fixes #1947.
CordovaActivity.createViewsaddsstatusBarViewtorootLayoutwithoutLayoutParamsand only sizes it insiderootLayout'sOnApplyWindowInsetsListener, so the view starts withFrameLayout's defaultMATCH_PARENT x MATCH_PARENT. On API 21–27 the listener never runs onceSYSTEM_UI_FLAG_LAYOUT_FULLSCREENis cleared (e.g. by cordova-plugin-statusbar's Android side forStatusBarOverlaysWebView=false):WindowCompat.setDecorFitsSystemWindows(window, false)is only emulated through that flag below API 30, and without it the decor'sfitsSystemWindowscontent root consumes the insets before they reachrootLayout(on API 28/29 the dispatch happens to continue because of the display-cutout part ofWindowInsets.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 bySystemBarPlugin— the app shows only a solid color after the splash screen. Full analysis with adumpsysview hierarchy in #1947.Description
Give
statusBarViewinitialLayoutParams(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 setsStatusBarBackgroundColor=#2A95D2(AndroidEdgeToEdgedefault). Before: full-screen colored view over the WebView (dumpsys activity top:View{… 0,0-1080,1848}aboveSystemWebView{… 0,0-1080,1848}). After: app visible, status bar as expected (View{… 0,0-1080,0}).StatusBarOverlaysWebViewtofalseon Android 7/8 usingcordova-plugin-statusbar#1947 for the hierarchies.The change was applied to cordova-android 15.1.0 via an
after_preparehook in our app for these tests (our app itself now avoids the trigger by not installing the statusbar plugin's Android side).npm run lintand the 337 JS specs pass;java-unit-testswas not run locally (no Android SDK on the machine used for the PR), the Java change was verified with the device builds above.Checklist
(platform)if this change only applies to one platform (e.g.(android)) — repo conventionfix(statusbar):used