android - AdView 缺少必需的 xml 属性 adSize

标签 android

我试图使用下面的代码显示添加。 我收到错误消息“AdView 缺少必需的 xml 属性 adSize”。

问题是什么?

主.xml:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" >

 <com.google.ads.AdView     
       android:id="@+id/adView"
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content"
       ads:adSize="BANNER"
       ads:adUnitId="a14f1d807e488dd" />
</LinearLayout>

属性.xml:

  <?xml version="1.0" encoding="utf-8"?>
     <resources>
     <declare-styleable name="com.google.ads.AdView">
     <attr name="adSize">
     <enum name="BANNER" value="1"/>
     <enum name="IAB_MRECT" value="2"/>
     <enum name="IAB_BANNER" value="3"/>
     <enum name="IAB_LEADERBOARD" value="4"/>
  </attr>
  <attr name="adUnitId" format="string"/>
 </declare-styleable>
</resources>

最佳答案

用这个

 <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
        android:id="@+id/add_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        ns:adSize="BANNER"
        ns:adUnitId="a14f1d807e488dd" >
    </com.google.ads.AdView>

 </Linearlayout>

关于android - AdView 缺少必需的 xml 属性 adSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9096764/

相关文章:

java - 我在使用 Android Studio 导入 ViewPager 时遇到问题?

java - 更改 AndroidImageSlider 中的指示器支架背景颜色

android - 使用 telephonymanager 获取 sim 序列号

android - 将大量数据下载到 android 的最有效方法?

android - ConstraintLayout 是否仍然优于 Jetpack Compose 中的嵌套列和行?

java - 如何共享使用 ImageView 功能的数组中的图像?

android - JSON 从 Android 发布到 Rails

android - 移动相机位置以适应关于标记高度的 LatLngBounds

java - 如何计算预定义日期时间和最近日期时间之间的秒数差异

android - 操作栏中的三点操作溢出菜单?