gpt4 book ai didi

android - AdMob 广告未展示。空间不足,无法展示广告

转载 作者:行者123 更新时间:2023-11-29 16:06:03 24 4
gpt4 key购买 nike

我试图将 AdMob 广告添加到我的应用程序中。我想在 ListView 下添加一个横幅,但没有显示任何广告,而且阅读日志似乎没有足够的空间来显示横幅。

08-17 20:11:00.976: E/Ads(7586): Not enough space to show ad! Wants: <320, 50>, Has: <992, 0>

最后这是我的整个布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
android:id="@+id/current_path_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/current_path"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ListView
android:id="@+id/list_of_files"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="XXXXXXXXXXXXX"
ads:loadAdOnCreate="true"
ads:testDevices="XXXXXXXXXXXXX" />
</LinearLayout>

</LinearLayout>

最佳答案

只需在 ListView 上定义权重....

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<TextView
android:id="@+id/current_path_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ding Chak"
android:textAppearance="?android:attr/textAppearanceLarge" />


<ListView
android:id="@+id/list_of_files"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="XXXXXXXXXXXXX"
ads:loadAdOnCreate="true"
ads:testDevices="XXXXXXXXXXXXX" />
</LinearLayout>

</LinearLayout>

关于android - AdMob 广告未展示。空间不足,无法展示广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18288692/

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