簡體   English   中英

AdMob橫幅廣告:沒有足夠的空間來展示廣告

[英]AdMob Banner: Not enough space to show ad

我想在我的應用程序中顯示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.

如何修復並顯示橫幅? 提前致謝。

如果需要,您的FrameLayoutRelativeLayout width應為wrap_content或0dp且weight等於1或等於兩個其他比例,此問題的原因是您的FrameLayout witdh設置為match_parent

如果要使用weight ,則應將LinearLayout方向更改為horizontal

您可以在manifest文件中的活動中添加android:windowSoftInputMode="adjustPan|adjustResize"

希望這會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM