question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 11 css safe-area-insets not applied

See original GitHub issue

Bug Report

Problem

  1. I created a clean cordova project (cordova create hello com.example.hello HelloWorld)
  2. Added cordova platform android 10.0.2
  3. Build the app on a device with a camera notch

=> The safe-area is considered.

  1. Run cordova platform remove android
  2. Run cordova platform add android@11.0.0
  3. 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:open
  • Created a year ago
  • Reactions:1
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ljudbanecommented, Aug 16, 2022

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

<item name="android:windowLayoutInDisplayCutoutMode">
            never
</item>

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 a values-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 😃

2reactions
kovacs-tamascommented, Nov 23, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found