【问题标题】:Android error: W/Ads: Not enough space to show ad. Needs 320x50 dp, but only has 384x0 dpAndroid 错误:W/Ads:没有足够的空间来展示广告。需要 320x50 dp,但只有 384x0 dp
【发布时间】:2017-07-04 22:30:27
【问题描述】:

其他人也有这个问题,但我的问题是独一无二的(我认为),只有当我在应用程序中打开键盘时才会出现此错误,例如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>

我该如何解决这个问题?

编辑:我不会费心解决这个问题,因为当键盘消失时广告会恢复正常,但是当键盘“触摸”视图时,视图会闪烁。

【问题讨论】:

  • 键盘一旦打开,广告就没有足够的空间了。看图像清楚地表明情况确实如此。没有余地了。你不清楚其中的哪一部分?这对您来说独特如何?没有可用于展示广告的屏幕空间。
  • @KenWhite 是的。没有足够的空间来展示广告。当键盘打开时,我该如何解决这个问题?这是独一无二的,因为没有人问过这个问题。
  • @KenWhite 查看我的编辑。

标签: java android xml


【解决方案1】:

通过添加修复

 android:windowSoftInputMode="adjustPan"

AndroidManifest.xml&lt;activity&lt;/&gt;

找到答案here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 2014-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多