gpt4 book ai didi

android-studio - "adSize"丢失

转载 作者:行者123 更新时间:2023-12-03 17:46:32 26 4
gpt4 key购买 nike

我正在尝试使用 Admob 在我的应用中转换广告。

但是,它一直说“缺少必需的 XML 属性“adSize””,即使该属性在我的 XML 文件中也是如此。

    <com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY UNIT ID"
ads:adSize="BANNER"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />

有人知道为什么会这样吗?

干杯。

最佳答案

确保你的布局有 xmlns:ads="http://schemas.android.com/apk/res-auto" 属性,还有为什么你有 layout_width 作为 fill_parent 而不是 wrap_content,所以也尝试更改它。

this tutorial如果你还没有。主要有activity_main.xml

您的整个 XML 布局文件也有助于解决问题。您可以删除不想发布的内容

或者,尝试将您的声明更改为以下内容,来自 this answer :

<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="YOUR_AD_UNIT_ID"
ads:adSize="BANNER"/>

人们还建议重新启动您的 IDE

关于android-studio - "adSize"丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35820595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com