Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Safe Area no longer works on Android #7908

Closed
1 of 3 tasks
rtarling opened this issue Mar 6, 2025 · 6 comments
Closed
1 of 3 tasks

[Bug]: Safe Area no longer works on Android #7908

rtarling opened this issue Mar 6, 2025 · 6 comments
Labels

Comments

@rtarling
Copy link

rtarling commented Mar 6, 2025

Capacitor Version

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1

Installed Dependencies:

@capacitor/core: 7.0.1
@capacitor/cli: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1

[success] Android looking great! 👌
[error] Xcode is not installed

Other API Details

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Since upgrading, safe area on android is not being preserved, with the contents of my header appearing where the notch is.

Expected Behavior

Content should start appearing below the notch.

Project Reproduction

Additional Information

No response

@rtarling rtarling added the triage label Mar 6, 2025
@maxnowack
Copy link

maxnowack commented Mar 6, 2025

I've got the same issue.
I've tried to get a workaround with capacitor-plugin-safe-area, but it doesn't get any valid values and logs
WindowInsets is not available

@rtarling
Copy link
Author

rtarling commented Mar 6, 2025

Luckily that plugin seems to have worked for me - I put the code in App.vue, but to be honest I'd rather not use it. If it was working fine before, something must have got broken in the latest release, and I'd prefer it to be fixed there.

In case you don't have the same, this needs to be in the index.html
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">

@nikqig
Copy link

nikqig commented Mar 6, 2025

Refer to these threads: 7804 & 30090

@AntoscencoVladimir
Copy link

Same issue

@jcesarmobile
Copy link
Member

Android 15 enforces edge to edge, the css safe-area-inset-top works fine, but not the safe-area-inset-bottom, that's a WebView bug and a there is a PR that should fix it, but it's not merged.

In Capacitor 7.1.0 we are adding a android.adjustMarginsForEdgeToEdge configuration option that would allow to make the WebView avoid the safe areas.

#7885

Android also provides a windowOptOutEdgeToEdgeEnforcement attribute that you can add in styles.xml to your theme and set it to true like this <item name="android:windowOptOutEdgeToEdgeEnforcement" tools:ignore="NewApi">true</item> to opt out of edge to edge, but having in mind that it will be removed in Android 16, so only works for Android 15.

@neave
Copy link

neave commented Mar 10, 2025

@jcesarmobile Thanks for this. Just to clarify, when android.adjustMarginsForEdgeToEdge is false it disables edge-to-edge, but when android.adjustMarginsForEdgeToEdge is true it will use the current behavior where safe-area-inset-bottom is not correct (0px)? If that’s the case, it seems that we can’t practically use edge-to-edge with Capacitor until the WebView bug fix is available. Is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants