You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 15中Stripe支付嵌入UI边缘到边缘模式覆盖系统栏问题

Android 15下Stripe Payment Drop-in UI覆盖系统栏的解决方法
  • 手动适配系统栏内边距
    Android 15强制启用edge-to-edge模式后,需要给Stripe Drop-in UI的容器动态添加与状态栏、导航栏高度匹配的内边距,避免内容被覆盖。可以通过WindowInsets获取系统栏高度并设置padding:

    // 在PaymentDropInActivity的根视图上设置(可通过自定义Activity或监听视图加载完成实现)
    val rootView = window.decorView.findViewById<ViewGroup>(android.R.id.content)
    rootView.setOnApplyWindowInsetsListener { view, insets ->
        val statusBarHeight = insets.getInsets(WindowInsets.Type.statusBars()).top
        val navBarHeight = insets.getInsets(WindowInsets.Type.navigationBars()).bottom
        view.setPadding(0, statusBarHeight, 0, navBarHeight)
        insets
    }
    
  • 自定义Stripe Drop-in主题
    通过配置自定义主题,明确系统栏颜色并禁止内容延伸到系统栏下方:

    1. 在styles.xml中定义主题:
      <style name="CustomStripeDropInTheme" parent="Theme.StripePaymentDefault">
          <item name="android:statusBarColor">@color/your_app_status_bar_color</item>
          <item name="android:navigationBarColor">@color/your_app_nav_bar_color</item>
          <item name="android:windowDrawsSystemBarBackgrounds">true</item>
          <item name="android:windowTranslucentStatus">false</item>
          <item name="android:windowTranslucentNavigation">false</item>
      </style>
      
    2. 启动Drop-in时指定该主题:
      val dropInConfig = PaymentDropInConfiguration.Builder(context, YOUR_STRIPE_PUBLISHABLE_KEY)
          .setThemeResId(R.style.CustomStripeDropInTheme)
          // 其他必要配置(如客户信息、支付Intent等)
          .build()
      PaymentDropInActivity.startPayment(context, dropInConfig)
      
  • 强制关闭内容延伸
    尝试在启动Drop-in前或在自定义的Stripe Activity中手动设置setDecorFitsSystemWindows(true),强制系统栏与内容区域分离:

    // 在Activity的onCreate方法中调用
    window.setDecorFitsSystemWindows(true)
    

    注意:此方法可能会改变Android 15默认的edge-to-edge表现,需要结合实际UI测试兼容性。

内容的提问来源于stack exchange,提问作者Omer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 00:05:02