gpt4 book ai didi

java - Admob 未在 ListView 布局中显示广告

转载 作者:太空宇宙 更新时间:2023-11-04 14:50:05 24 4
gpt4 key购买 nike

当我将广告 View 放入包含 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:

<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>

关于java - Admob 未在 ListView 布局中显示广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23894986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com