[英]Admob not showing ad in a layout with listview
将广告视图放入包含列表视图的布局中时,我的广告没有展示。 这是我的XML代码:
<?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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1596992408570157/3380743224" />
</LinearLayout>
我收到此LogCat错误消息:“广告空间不足。需要960 X 150像素,但只有1080 X 75像素。”
我尝试将广告放置在列表视图之前,并且可以正常运行,但这不是我想要的。
ListView
高度占用了父级的整个空间。
尝试将您的ListView
替换为以下内容:
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.