FrameLayout下面的Admob横幅

Dro*_*nie 1 java android admob android-studio

我在现有项目中创建了一个admob横幅。在相对布局中,我正在调用FrameLayout并在admob横幅的代码下方。但是问题是Admob标语显示在框架布局内容上方。

我的XML代码如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:ads="http://schemas.android.com/apk/res-auto">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar"/>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_home_footer"
        ads:background="@color/theme_ads"
        android:layout_alignParentBottom="true">
    </com.google.android.gms.ads.AdView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

布局

根据admob政策,我们不应将广告置于内容之上。我该如何解决这个问题?

Rav*_*avi 5

设置你的FrameLayout上方AdView

<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/adView"
    android:layout_below="@id/toolbar"/>
Run Code Online (Sandbox Code Playgroud)