AdMob的"没有足够的空间来显示广告和QUOT;错误没有足够、错误、广告、空间

2023-09-08 15:52:42 作者:▍凉冬空巷°

我是新来的Andr​​oid。 我说的AdMob在我的Andr​​oid应用程序通过在main.xml中的以下变化:

 < XML版本=1.0编码=UTF-8&GT?;
< TabHost的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / tabhost
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT>

    <的LinearLayout
        的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:方向=垂直>
        < TabWidget
            机器人:ID =@机器人:ID /标签
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT/>

        <的FrameLayout
            机器人:ID =@机器人:ID / tabcontent
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT/>

        < com.google.ads.AdView
            的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
            机器人:ID =@ + ID / AD浏览报
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            广告:adSize =大旗
            广告:adUnitId =XXXXXXXXX
            广告:loadAdOnCreate =真/>
    < / LinearLayout中>
< / TabHost>
 

我的项目是成功的,没有错误运行,但我没有收到广告。

  WARN /广告(3805):没有足够的空间来显示广告!想:其中; 320,50>中有:其中; 320,0取代。
 

解决方案

这意味着是在你的布局中显示的广告没有空间。将其更改为RelativeLayout的和调整父底部。

 < RelativeLayout的
            的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            >
        < TabWidget
                机器人:ID =@机器人:ID /标签
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT/>
        <的FrameLayout
                机器人:ID =@机器人:ID / tabcontent
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT
                机器人:layout_below =@机器人:ID /标签/>

    < com.google.ads.AdView
            的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
            机器人:ID =@ + ID / AD浏览报
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:layout_alignParentBottom =真
            广告:adSize =大旗
            广告:adUnitId =XXXXXXXXX
            广告:loadAdOnCreate =真
            />
< / RelativeLayout的>
 
受够了广告 原来电脑也能设置免打扰

I'm new to Android. I added AdMob in my android app by making the following changes in main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />

        <com.google.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            ads:adSize="BANNER"
            ads:adUnitId="XXXXXXXXX"
            ads:loadAdOnCreate="true" />
    </LinearLayout>
</TabHost>

My project is successfully running with no error, but I'm not getting the ad.

WARN/Ads(3805): Not enough space to show ad! Wants: <320, 50>, Has: <320, 0>.

解决方案

It means there is no space for to display ad in your layout. Change it to RelativeLayout and align parent bottom.

<RelativeLayout
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
        <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@android:id/tabs"/>

    <com.google.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="XXXXXXXXX"
            ads:loadAdOnCreate="true" 
            />
</RelativeLayout>

 
精彩推荐
图片推荐