2015-06-07 86 views
1

我正在嘗試在我的應用程序中顯示Google的橫幅廣告。我有這個佈局(activity_main):AdMob Banner:沒有足夠的空間來顯示廣告

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

如何解決它,並顯示橫幅廣告嗎?提前致謝。如果你想

回答

1

FrameLayoutRelativeLayoutwidthwrap_content,或0dp和weight等於1雙方還是其他比例,對於這個問題的原因是你的FrameLayoutwitdh設置爲match_parent

如果你要使用weight您應將LinearLayout方向改變爲horizontal

+0

還需要將AdView封裝在RelativeLayout中。 – Psypher

0

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

希望這會有所幫助。

相關問題