What is correct xmlns url for AdMob in Android Lay

2020-02-13 02:48发布

I am testing the AdMob for Android SDK. I can't set the admob:testing="true" because the admob attribute is unknown.

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:admob="http://schemas.android.com/apk/res/org.ifies.android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:background="#FF000000"
  android:clickable="true"
>
  <com.admob.android.ads.AdView  
    android:id="@+id/admob" 
    android:visibility="visible"
    android:layout_width="fill_parent" 
    android:layout_height="100px"
    android:background="#FF0000"
    admob:testing="true"
  />
</LinearLayout>

My Eclipse is complaining that admob:testing="true" would have an unknown prefix. Anyone got an idea on how to fix this?

Sub question: Anyone got an idea how to change the height of the ad? It seems to be fixed to 48px, which is not looking good on any DROID phone...

2条回答
Rolldiameter
2楼-- · 2020-02-13 03:23

Might be worth checking that the error isn't due to something outside the file:

Make sure the package name you are using in your schema URI, "org.ifies.android", matches the value of the package attribute on the manifest element in AndroidManifest.xml.

Make sure res/values/attrs.xml has the attributes specified:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="com.admob.android.ads.AdView">
        <attr name="testing" format="boolean" />
        <attr name="backgroundColor" format="color" />
        <attr name="textColor" format="color" />
        <attr name="keywords" format="string" />
        <attr name="refreshInterval" format="integer" />
        <attr name="isGoneWithoutAd" format="boolean" />
    </declare-styleable>
</resources>
查看更多
We Are One
3楼-- · 2020-02-13 03:25

This took me a while to figure out, so I am posting it here:

Since AdMob 4.1 this has changed, so the previous answer is correct for versions <=4.04. Now you need to use:

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

No place for your own package in the new schema and no need for an attrs.xml file.

Details here: http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 (Tim's post, it's the 8th from the top)

查看更多
登录 后发表回答