Reputation: 361
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>
As per the admob policy we should not place ads above content. How can I resolve this issue?
Upvotes: 1
Views: 2008
Reputation: 27221
Wrap by another RelativeLayout;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/inner_rel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" >
<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"/>
</RelativeLayout>
</LinearLayout>
<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>
Upvotes: 0
Reputation: 35589
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"/>
Upvotes: 6