Reputation: 53
I'm having some problems trying to integrate an admob banner in my app.
I create an adView via xml
<LinearLayout
android:id="@+id/bannerLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/button2" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent"
ads:adSize="BANNER"
ads:adUnitId="@string/adMobIDSmall" />
</LinearLayout>
And in my main activity I invoke admob like this
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Emulator
.addTestDevice("001917fb63241f")
.build();
adView.loadAd(adRequest);
But when I run my application in my SG SII I get this error message:
Its like Admob is ignoring the size of the banner I'm requesting. I've tried everything and I'm running out of ideas :(
Thanks in advance,
Upvotes: 4
Views: 1739
Reputation: 53
Thanks for your answer,
I finally get the solution, Eclipse by default puts the following information on the main layout:
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
Removing this lines makes the trick :D
Upvotes: 1
Reputation: 10368
It might because that your root layout has padding/margins. On a 800X480 screen, you should make sure the banner is occupying the whole width of the display area.
Upvotes: 0
Reputation: 20196
It doesn't look like you have posted the entire layout XML. I suspect you have padding or set a margin for one of the elements enclosing @id/bannerLayout. Remove the padding/margin (nb it might be in a style you have applied).
I also suggest you alter the layout_width and layout_eights as follows:
<LinearLayout
android:id="@+id/bannerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/button2" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/adMobIDSmall" />
</LinearLayout>
Upvotes: 1
Reputation: 11323
If you use:
ads:adSize="SMART_BANNER"
instead of:
ads:adSize="BANNER"
then the banner should adjust to the screen size.
BTW: it is weird that your available screen size is so small (432x690) => You should review the layout file where your banner-layout snippet is.
Upvotes: 2