embersofadyingfire
embersofadyingfire

Reputation: 533

Admob ad not showing due to not having enough space

I have implemented Admob ads in a project of mine. I'm using the latest version of Eclipse; Juno Service Release 1, with the latest updates. When I updated, I noticed that there are automatic additions to xml layout files; the @dimension/ references, like so:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   ...
   ...
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   ...
   ...

When I run the app on my Nexus 7, the ads do not show, and I get an error that says the ad does not have enough space to show. After messing around with this, I found that if I remove the @dimension/ references, the error goes away, and the ad appears. I don't want to have to go back to all my layout files to remove the @dimension/ references, so I'm asking for help in identifying a way around this problem. There has to be a way to make the ad work without deleting the @dimension/ references; is there?

Upvotes: 0

Views: 158

Answers (2)

Ravi
Ravi

Reputation: 35549

just remove

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

from your relative layout and problem is solved

Upvotes: 1

Eric Leichtenschlag
Eric Leichtenschlag

Reputation: 8931

Another way to effectively do this is just go into dimens.xml and set the left and right padding to 0. That is, if you don't want the padding in any of your activities.

You're probably using SMART_BANNER AdSize, which unfortunately expects the entire screen (without padding), so there isn't a better way around this.

Upvotes: 3

Related Questions