[英]AdMob Banner: Not enough space to show ad
i'm tring to show a Google's banner inside my application. 我想在我的应用程序中显示Google的横幅。 I've this layout (activity_main):
我有这个布局(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>
When i run my app i see in the logcat this error: 当我运行我的应用程序时,我在logcat中看到此错误:
Not enough space to show ad. Needs 320x50 dp, but only has 360x0 dp.
How can i fix it and show the banner? 如何修复并显示横幅? Thanks in advance.
提前致谢。
Your FrameLayout
and RelativeLayout
width
should be wrap_content
, or 0dp and weight
equals to 1 for both or other proportions if you want, the reason for this issue is that your FrameLayout
witdh
is set to match_parent
如果需要,您的
FrameLayout
和RelativeLayout
width
应为wrap_content
或0dp且weight
等于1或等于两个其他比例,此问题的原因是您的FrameLayout
witdh
设置为match_parent
And if you want to use weight
you should change your LinearLayout
orientation to horizontal
如果要使用
weight
,则应将LinearLayout
方向更改为horizontal
You can add android:windowSoftInputMode="adjustPan|adjustResize"
to the activity in your manifest
file. 您可以在
manifest
文件中的活动中添加android:windowSoftInputMode="adjustPan|adjustResize"
。
Hope this will help. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.