Skip to content

[Bug]: adjustMarginsForEdgeToEdge Not Working on Android (Capacitor 7.1.0) #7916

@ckoon-infopro

Description

@ckoon-infopro

Capacitor Version

Capacitor Doctor

Latest Dependencies:

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

Installed Dependencies:

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

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

Other API Details

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

The new adjustMarginsForEdgeToEdge feature introduced in Capacitor 7.1.0 does not appear to be working as expected. I have installed Capacitor 7.1.0, set this option to 'auto' and 'force' in my configuration, but margins are not being adjusted accordingly.

Expected Behavior

When set to "force", margins should always be adjusted for edge-to-edge display.
When set to "auto", margins should be adjusted if running on Android 15 and windowOptOutEdgeToEdgeEnforcement is false or missing.

Project Reproduction

Any Android project with Capacitor 7.1.0 installed.

Additional Information

After some troubleshooting, I found that the following check fails:

if (webView instanceof CapacitorWebView capacitorWebView) {
    capacitorWebView.setBridge(bridge);
    capacitorWebView.edgeToEdgeHandler(bridge);
}

The edgeToEdgeHandler method does not get called because webView is not an instance of CapacitorWebView. This seems to be preventing the margins from being adjusted as expected.

Could this be a bug, or is there an additional setup required to ensure webView is correctly recognized as a CapacitorWebView?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproductionneeds reproducible example to illustrate the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions