简体   繁体   中英

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

Others too have this issue, but mine is unique (I think) in that this error only occurs when I open the keyboard within the app like this . It does not happen when the keyboard is not opened.

Again, the error is:

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

Here is the 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>

How do I go about fixing this?

EDIT: I wouldn't bother fixing this, because the ad returns back to normal when the keyboard goes away, BUT Views flicker when the keyboard 'touches' a view.

Fixed by adding

 android:windowSoftInputMode="adjustPan"

to AndroidManifest.xml under <activity</>

Answer found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM