Android AdMob";没有足够的空间显示广告“;错误
我不熟悉安卓系统。 我通过在main.xml中进行以下更改,在android应用程序中添加了AdMob:Android AdMob";没有足够的空间显示广告“;错误,android,android-layout,android-emulator,admob,Android,Android Layout,Android Emulator,Admob,我不熟悉安卓系统。 我通过在main.xml中进行以下更改,在android应用程序中添加了AdMob: <?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" a
<?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>
我的项目正在顺利运行,没有错误,但我没有收到广告
WARN/Ads(3805): Not enough space to show ad! Wants: <320, 50>, Has: <320, 0>.
WARN/Ads(3805):没有足够的空间显示广告!想要:,有:。
这意味着版面中没有显示广告的空间。将其更改为RelativeLayout并将父对象底部对齐
<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>
这是导致问题的原因
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
您的FrameLayout占据了视图的所有高度。因此,即使您在FrameLayout下方写入AdView,它的高度也将为0
Concider在运行时将AdMob包含在FrameLayout中。此警告清楚地告诉您,用于显示广告的空间不足。它需要320x50空间,高度为0。请检查您的adview是否有适当的空间。并将不推荐使用的FrameLayout替换为位于中心的RelativeLayout(此处不相关,但不会有任何影响)。我尝试了layout_alignTop。但不起作用。您的TabHost可能有问题。通过将颜色设置为RelativeLayout android:background=“@android:color/white”进行交叉检查,检查广告是否位于版面底部