Android错误:广告:没有足够的空间来展示广告。需要320x50 dp,但只有384x0 dp

时间:2017-02-16 01:42:27

标签: java android xml

其他人也有这个问题,但我的独特之处(我认为)只有当我在应用程序中打开键盘this时才会出现此错误。键盘未打开时不会发生这种情况。

同样,错误是:

W/Ads: Not enough space to show ad. Needs 320x50 dp, but only has 384x0 dp.

这是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"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">

<EditText
    android:id="@+id/input"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="Enter your Number"
    android:textAlignment="center"
    android:layout_gravity="center"
    android:inputType="text"
    android:ems="25"
    android:textColor="@color/colorPrimary"
    android:textSize="20sp"
    android:maxLength="31"
    android:layout_marginTop="30dp"
    android:layout_marginBottom="45dp"/>

<TextView
    android:id="@+id/from"
    android:text="@string/from"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textColor="@color/colorPrimary"
    android:textSize="16sp" />

<Spinner
    android:id="@+id/spinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:entries="@array/spinner_entries1"
    android:background="@null"
    android:layout_marginBottom="25dp"/>

<TextView
    android:id="@+id/to"
    android:text="@string/to"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textColor="@color/colorPrimary"
    android:textSize="16sp" />

<Spinner
    android:id="@+id/spinner2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@null"
    android:cursorVisible="false"
    android:entries="@array/spinner_entries2"
    android:layout_marginBottom="20dp"/>

<EditText
    android:id="@+id/output"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAlignment="center"
    android:layout_gravity="center"
    android:inputType="text"
    android:ems="25"
    android:textColor="@color/colorPrimary"
    android:textSize="20sp"
    android:maxLength="31"
    android:layout_marginBottom="30dp" />

<Button
    android:id="@+id/button"
    android:text="@string/button_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:textColor="#FFFFFF"
    android:onClick="convert"
    android:layout_gravity="center" />

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    ads:adSize="BANNER"
    ads:adUnitId="@string/admob_id"
    android:layout_marginTop="50dp"
    />

</LinearLayout>

我该如何解决这个问题?

编辑:我不打算解决此问题,因为当键盘消失时广告会恢复正常,但当键盘触及时,视图会闪烁。一个观点。

1 个答案:

答案 0 :(得分:0)

通过添加

修复
 android:windowSoftInputMode="adjustPan"

AndroidManifest.xml

下的<activity</>

找到答案here