Droid Genie Droid Genie - 2 months ago 20
Java Question

Admob Banner below a FrameLayout

I am creating an admob banner in my existing project. Inside a relative Layout, I am calling a FrameLayout and below the code for admob banner. But the problem is that Admob banner is displaying above the framelayout content.

My XML Code is as follows

<?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>


layout

As per the admob policy we should not place ads above content. How can I resolve this issue?

Answer

set your FrameLayout above 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"/>
Comments