Android的Admob的没有足够的空间来展示广告 [英] Android Admob Not enough space to show ad
问题描述
用于在 AdMob的网站
下面是我的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_img"
android:orientation="vertical"
android:id="@+id/atozlayout"
>
<GridView
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="55dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
>
</GridView>
</LinearLayout>
但logcat的节目 E /广告(4244):没有足够的空间来显示广告!想:其中,480,75>,有:其中,800,0>
But the logcat shows E/Ads(4244): Not enough space to show ad! Wants: <480, 75>, Has: <800, 0>
好像布局产生的问题。请建议的方法来解决。非常感谢。
Seems like the layout is creating issue. Please suggest way to fix. Many Thanks.
推荐答案
您电网正在与 layout_height =FILL_PARENT所有的空间。
您可以使用 layout_weight =1和 layout_height =0dp告诉电网为占用所有剩余的空间后,其它视图显示。
You can use layout_weight="1" and layout_height="0dp" to tell the grid to take up all the remaining space after other views are shown.
另外要补充的编程AD浏览?你可以将其放置在GridView控件下面的XML。
Also are you adding the AdView programmatically? You can place it in the xml below the GridView.
例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_img"
android:orientation="vertical"
android:id="@+id/atozlayout"
>
<GridView
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:columnWidth="55dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp">
</GridView>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_AD_UNIT_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>
</LinearLayout>
请确保您与您的值替换adUnitId。
Make sure you replace adUnitId with your value.
这篇关于Android的Admob的没有足够的空间来展示广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!