Android 11 css safe-area-insets not applied
See original GitHub issueBug Report
Problem
- I created a clean cordova project (
cordova create hello com.example.hello HelloWorld
) - Added cordova platform android 10.0.2
- Build the app on a device with a camera notch
=> The safe-area is considered.
- Run
cordova platform remove android
- Run
cordova platform add android@11.0.0
- Run
cordova run android
=> The safe-area is not considered anymore
Only change I made in the config.xml
:
<preference name="Fullscreen" value="true" />
What is expected to happen?
Using css padding safe-area-insets should add a safe-area padding
What does actually happen?
The padding for the safe-area is not added when using android@11.0.0
Information
Command or Code
Environment, Platform, Device
- Huawei P30 Lite, Android
- Google Pixel 6
Version information
cordova: 11.0.0 npm 8.11.0
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:18 (6 by maintainers)
Top Results From Across the Web
env(safe-area-inset-top) not working on Android Pie + ...
Show activity on this post. I have a fullscreen cordova app, I used to use the css below for iPhone X's notch, padding-top:...
Read more >1503656 - Android cutout support for CSS env() safe area insets
No binding interface for safe area implementation. Bug 1462233 uses hardcoded value for safe area. Tiger Oakes ...
Read more >1094366 - safe-area-inset-* values are always 0px in webview
Run the iOS app on a device with a notch (example: iPhone 11). ... The CSS values should be propagated from Android.
Read more >How to Handle Safe Area Insets for iPhone X, iPad X, Android P
The tips provided in this guide apply for both iOS and Android and are ... iOS 11 SDK, the navigation bar does not...
Read more >How to Use Safe Area Context in React Native Apps to Avoid ...
Status bar overlaps the content of the screen on Android ... this component is only applicable to iOS devices with iOS version 11...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
While further exploring this issue i found this resource: https://developer.android.com/guide/topics/display-cutout.
The way the cutout behaves, can be defined in manifest inside <style>. So i tried adding
to file
platforms/android/app/src/main/res/values/themes.xml
and i got the top black bar back. The Android studio warned me that this option was only available from some Android version on so i let it create avalues-v27/themes.xml
override file.As to why the default behaviour changed, i don’t know. Maybe because we target higher API version now. Or because theme on main activity was changed to
@style/Theme.App.SplashScreen
.Since i need a quick solution to this i will be creating a after_platform_add hook in my project that will create a
values-v27/themes.xml
file in the Android project.Maybe in the future this could be controlled with a setting in config.xml 😃
Looks like the latest Android System WebView (107.0.5304.105) solved the problem. I’ve checked with 108.* Beta and 109.* Dev builds also, they work well