我想在我的应用程序中显示 Google 的横幅。我有这个布局(activity_main):
<?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-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</LinearLayout>
当我运行我的应用程序时,我在 logcat 中看到这个错误:
Not enough space to show ad. Needs 320x50 dp, but only has 360x0 dp.
如何修复它并显示横幅?提前致谢。
最佳答案
你的 FrameLayout
和 RelativeLayout
width
应该是 wrap_content
,或者 0dp 和 weight
如果您愿意,两者或其他比例都等于 1,出现此问题的原因是您的 FrameLayout
witdh
设置为 match_parent
如果你想使用 weight
你应该改变你的 LinearLayout
方向到 horizontal
关于java - AdMob 横幅 : Not enough space to show ad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30693731/