[英]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.
如何修復並顯示橫幅? 提前致謝。
如果需要,您的FrameLayout
和RelativeLayout
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.