代码之家  ›  专栏  ›  技术社区  ›  Vidar Vestnes

android布局xml中admob的正确xmlns url是什么

  •  2
  • Vidar Vestnes  · 技术社区  · 15 年前

    我正在测试admob for android sdk。我无法设置 admob:testing="true" 因为admob属性未知。

    <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>
    

    我的日食在抱怨 admob:testing=“真” 会有一个未知的前缀。有人知道怎么解决这个问题吗?

    子问题:有人知道如何改变广告的高度吗?它似乎被固定在48px,这在任何机器人手机上看起来都不好…

    2 回复  |  直到 13 年前
        1
  •  5
  •   Lance Nanek    15 年前

    可能值得检查错误不是由于文件以外的原因造成的:

    确保您在模式uri“org.ifies.android”中使用的包名与android manifest.xml中manifest元素的package属性值匹配。

    确保res/values/attrs.xml具有指定的属性:

    <?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>
    
        2
  •  7
  •   Aleadam    13 年前

    我花了一段时间才弄明白,所以我把它贴在这里:

    因为admob 4.1已经改变了这一点,所以前面的答案对于版本<=4.04是正确的。现在您需要使用:

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

    在新模式中没有您自己的包的位置,也不需要attrs.xml文件。

    详情如下: http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 (蒂姆的帖子,上面是第8条)