Reputation: 41
I have a live application and use admob banner in it. today i received an warning "ADS AND CONTENT OVERLAP"
This is my xml code where i place ads banner
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.white.kora.Main" >
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_alignParentTop="true"
style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/progressbar_Horizontal"
android:max="100"
android:background="#228b22"
/>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|center|end"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx"></com.google.android.gms.ads.AdView>
How i could use admob banner with webview correctly?
Upvotes: 1
Views: 3722
Reputation: 445
Just wanted to post what I had to do to remove the violation with my banner ad which is placed at the bottom of each view.
This places a banner ad at the bottom of the screen:
<com.google.android.gms.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:visibility="gone"
com.google.android.gms:adSize="SMART_BANNER"
com.google.android.gms:adUnitId="ca-app-pub-xxxxx"
googleads:adUnitId="ca-app-pub-xxxxx" />
Ensure the parent view (Relative/Linear layout etc) above the banner has:
android:layout_above="@+id/adView"
You might also find you need to add a margin above the ad:
android:layout_marginTop="8dp"
or below your content:
android:layout_marginBottom="8dp"
This link had more useful information then the "learn more" about this violation link in admob:
https://support.google.com/admob/answer/6275335?hl=en&ref_topic=2745287
The above steps will remove the "overlap" violation. I went through the layout of my entire app (about 50 layouts) and any with an ad I explicitly had to set this. Even though the app visibly might look fine to users (eg a banner ad is at the bottom of the screen correctly) I suspect a bot is checking from the admob side as I got no communication back when I emailed them and rejections were really quick (1 hour). It took more than 10 attempts to remove the violation.
Upvotes: 2
Reputation: 2321
Add below attributes to Webview.
android:layout_above="@+id/adView"
Upvotes: 5