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

Max Applovin Banner Ad运行时未显示在底部(Android Studio设计正常)

问题分析与修复方案

你的核心问题是CoordinatorLayout下的子View层级覆盖导致广告显示异常:外层LinearLayout设置了match_parent高度,会占据整个布局空间,把下方的MaxAdView部分遮挡;同时在CoordinatorLayout中仅用android:layout_gravity="bottom"不足以确保广告不被上层View覆盖。

修复步骤

方案一:调整LinearLayout布局,给广告预留空间

将外层LinearLayout的高度设置为match_parent,同时添加底部边距等于广告高度,让LinearLayout不占满底部区域:

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="@dimen/banner_height">
    <!-- 内部的AppBarLayout、ViewPager2等内容保持不变 -->
</LinearLayout>

方案二:优化MaxAdView的布局属性(推荐)

给MaxAdView添加CoordinatorLayout专属的布局行为,确保它固定在底部且不被其他View遮挡:

<com.applovin.mediation.ads.MaxAdView
    maxads:adUnitId="deb0327b3f01cdb9"
    android:background="@color/banner_background_color"
    android:layout_width="match_parent"
    android:layout_height="@dimen/banner_height"
    android:layout_gravity="bottom"
    app:layout_dodgeInsetEdges="bottom" />

额外检查项

  1. 确认@dimen/banner_height的数值合理:标准Banner广告高度为50dp,自适应Banner可设为wrap_content,避免固定高度过小导致显示不全。
  2. 若使用自适应Banner,建议在代码中动态设置尺寸:
maxAdView.setAdSize(MaxAdSize.BANNER); // 或MaxAdSize.MEDIUM_RECTANGLE等

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 15:15:32