List of AdMob attributes used in xml and in extras - android

Searching through the web didn't give me the reference to neither the attributes which may be used when setting up AdMob's AdView in xml, nor the valid values used as AdRequest.extras.
The official documentation on AdView in XML gives just following example:
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>
While the guide on extras specifies just following values:
color_bg Background color
color_bg_top Gradient background color at top
color_border Border color
color_link Link text color
color_text Text color
color_url URL color
So, are these values the only possible way to customize (not considering Targeting) the AdView and AdRequest or are there any unmentioned values/attributes?

The AdView also has an ads:keywords attribute which takes in a comma separated list of keywords. AdMob doesn't use the keywords at all though - it just passes them to AdSense backfill if you have that enabled.
I'm not aware of any other extras that AdMob itself uses. For those who are using DoubleClick for Publishers with AdMob, you can use the extras for custom targetting of your ad inventory.

Related

What is the appropriate value for adSize in the xml file if I want to include an InterstitialAd and not a Banner?

What is the appropriate value for adSize in the xml file if I want to include an InterstitialAd and not a Banner?
My problem is that including an InterstitialAd from Admin to my application does not work properly.
So far I followed the official tutorial, but it says nothing about the value of ads:adSize in the xml. When I implemented a ad with a banner this attribute was set with "BANNER" but I suppose this is not the solution when I want to have an Interstitial ad.
So could you please tell me which other values than BANNER are possible for ads:adSize or what else I should use to make it work?
Thanks a lot
Below code required only when you want to add banner view at your App view.
<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_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
Follow instruction of this link to implement InterstitialAd in your App.

How to style admob in xml?

I am currently trying to theme an admob view and that work fine in Java code:
.addExtra("color_bg", "6D0504")
.addExtra("color_bg_top", "6D0504")
.addExtra("color_border", "6D0504")
.addExtra("color_link", "000080")
.addExtra("color_text", "808080")
.addExtra("color_url", "008000");
I could indeed make it work like this.
But i would like to work with xml and all the temptative I have tried have failed so far...
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="XXX"
ads:refreshInterval="60"/>
Something like
ads:color_bg="#6D0504"
does not work at all and I cannot find any inforùation in the official doc:
https://developers.google.com/mobile-ads-sdk/docs/admob/best-practices#adcolors
Any help would be highly appreciated.
You can style background and text color online in AdMob>Sites&Apps>App Settings (click here for direct link) and then setting Ad style to "use color set below:" where you can specify your own colors.
There are also some other interesting settings in that page, such as autorefresh rate.

Why won't my Admob Ads show up in my android application?

I have made an application for the Android Market and I tried to include an Ad in it using Admob. I have everything set up correctly, but the ad doesn't show up no matter what I do. If I check the Admob Marketplace I can see that there were a lot of requests sent and I got a good fillrate, too, but my ads simply do not show up in my program, as if they were invisible.
The AdView appears if I am in the graphical XML designer, but just won't show up when I run the program, although as I said, it sends a request. I would really appreciate it if you could help me out! :)
By the way, here is the main code of the AdView(I tried to add it using Java too, but it didn't show up either):
<com.google.ads.AdView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ad"
ads:loadAdOnCreate="true"
ads:adSize="BANNER"
ads:adUnitId="MyIdHere">
</com.google.ads.AdView>
I found out that the padding of my layout prevented the Adview from
appearing. Removing the padding fixes the problem!
-- answer by Calin

Android/Admob: Can I set a list of testing devices in the Layout XML for the AdView?

So, I currently have an AdView in my layout like this:
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="XXXXXXXXXXXXXX"
ads:adSize="BANNER"
ads:loadAdOnCreate="false"/>
and that works just fine. However, I have to get the AdView in the source code in order to pass it a request for the Emulator and my personal phone to be TestingDevices and not receive real ads. Is there a way I can list those in the XML directly? or even force the AdView to ONLY show test ads, so that I don't have to have that chunk of code and can set the AdView to loadAdOnCreate?
Thanks.
Sure, add this to the xml:
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
I found it here: https://developers.google.com/mobile-ads-sdk/docs/android/banner_xml

Managing Admob publisher ID from a central place with multiple ad placements

So, with new google-admob SDK for android correct way to place banner ad in the layout is for example like this :
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"
ads:adUnitId="some id"
ads:adSize="BANNER"/>
My problem is that I have multiple banner ads throughout various activities and when I for some reason want to change adUnitId I do not want to chase this snippet of code through all my xml layout files. I want to have one place where I define my adUnitId that all banner ads in the app uses. That was possible in the previous admob-only SDK, by setting meta data in manifest file. And I do not want to layout AdView in Java code, want it to be in xml if possible with the new SDK.
I tried with something like this :
ads:adUnitId="#string/admob_id"
but it just see it as a string as I can see, not following through to the actual string defined in the strings.xml. Any ideas?
With the newest admob update, I was forced to do most of my AdMob activities in my Java classes. This is how I made it work (with a centralized ID):
ad = new AdView(this, AdSize.BANNER, UtilClass.AD_PUBLISHER_ID); //Ad is the global AdView
LinearLayout layout = (LinearLayout) findViewById(R.id.main_admob_layout);
Edit: I keep the LinearLayout definition in the xml files so the positioning is all done throughout the xml:
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="bottom" android:weightSum="0"
android:layout_alignParentBottom="true" android:id="#+id/main_admob_layout">

Categories

Resources