Search code examples
androidstripe-paymentsedge-to-edge

Edge to Edge issue with Stripe UI - Android


In Android 15, edge-to-edge mode is enabled by default, and I am unable to disable it. I'm using the Stripe Payment Drop-in UI, but the issue I'm facing is that the activity is covering both the status bar and the navigation bar, as shown in the attached image.

enter image description here

I've ensured that the Stripe library is up-to-date, but I'm still encountering this issue. How can I prevent the activity from covering the system bars in this scenario?

Any help or guidance would be appreciated!


Solution

  • Android 15 has provided an opt-out way for Activities that does not ready for edge-to-edge.
    But it's not documented in Android 15 behavior changes, it's documented in API reference instead:

    R.attr.windowOptOutEdgeToEdgeEnforcement

    To use it, you can define a theme style for your third party Activities.

    1. Define a theme base on the Activity's base theme, for example an AppCompat.NoActionBar theme:
        <style name="Theme.AppCompat.DayNight.NoActionBar.WindowOptOutEdgeToEdge" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
            <!-- Attribute windowOptOutEdgeToEdgeEnforcement is override in values-v35 -->
        </style>
    
    1. Override it in values-v35:
        <!-- Set windowOptOutEdgeToEdgeEnforcement to true until edge-to-edge is supported by your activity itself -->
        <style name="Theme.AppCompat.DayNight.NoActionBar.WindowOptOutEdgeToEdge" parent="@style/Theme.AppCompat.DayNight.NoActionBar">
            <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
        </style>
    
    1. Add your third party activity to AndroidManifest.xml, and set it's theme to "WindowOptOutEdgeToEdge":
            <activity
               android:name="xx.xx.xx.YourThirdPartyActivity"
                android:exported="false"
                android:theme="@style/Theme.AppCompat.DayNight.NoActionBar.WindowOptOutEdgeToEdge" />
    
    1. Have fun.