java - Admob 横幅广告空间不足

标签 java android eclipse admob banner

我不知道如何解决这个问题。我收到错误

Not enough space to show ad. Needs 360x50 dp, but only has 350x582 dp .

这是我的布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
android:orientation="vertical"
>

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textMultiLine"
    android:maxLines="4"
    android:textSize="20dp" />

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/button1"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Copy" />

    <ImageView
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:id="@+id/imageView1"
        android:onClick="keyBoardClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/keyboard" />

    <Button
        android:id="@+id/button2"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Share" />
</LinearLayout>

<GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="center"
    android:numColumns="8" >
</GridView>

 <com.google.android.gms.ads.AdView
     android:id="@+id/adView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     ads:adSize="SMART_BANNER"
     ads:adUnitId="myAdMobID" >

</com.google.android.gms.ads.AdView>  

那里出了什么问题,因为我在 adView 上有宽度的 match_parent 和高度的换行内容。

最佳答案

AdMob 可能会或可能不会提示“有足够的空间”,但如果父 View 中有填充,它就不会显示。您需要将想要有填充的 View 包装在另一个布局中,或者直接向该特定 View 添加填充。

请从父布局中删除内边距:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>

关于java - Admob 横幅广告空间不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31775760/

相关文章:

java - 如何让两台计算机用java相互通信以进行即时通讯?

java - 如何使用 xsd 验证 xml?

java - Android Studio 在调试器中看不到静态 : no such static field

java - Appium - 弹出警报消息没有被关闭

java - 是否可以在使用 Java 9 的 Eclipse IDE 中使用没有类和主要方法的 sysout?

java - 无法在 Eclipse Kepler 中找到 JavaFX 透视图

java - 从 LinkedList 的构造函数调用非最终 addAll 方法

java - 由 : org. apache.camel.NoTypeConversionAvailableException 引起:没有可用于从类型 POJO 转换为 byte[] 的类型转换器

android - ListView addHeaderView 导致位置加一?

java - 如何在eclipse项目中共享代码