Search code examples
androidkeyboard

An extra keyboard is showing every time I press "done" in the main keyboard in my activity


I have a problem that I'm facing after I inserted Ad Banner to my Activity.

After I use the soft keyboard to insert numbers into my edit text, when I press done, a useless text keyboard automatically appears out of nowhere. Its buttons are disabled, they don't do anything, and I have to press the back button on my device to get rid of it.

Here is the numeric keyboard before I press "done"

enter image description here

And here is the extra keyboard that I don't know where it is coming from after I press "done"

enter image description here

My MainActivity is below

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >

        <include layout="@layout/toolbar_layout" />

        <FrameLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolBar"
            >
        </FrameLayout>
        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/AdBanner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">

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


    </RelativeLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigationView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:menu="@menu/navigation_menu"></android.support.design.widget.NavigationView>



</android.support.v4.widget.DrawerLayout>

And this shown fragment code is

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    tools:context=".checkTicketFrag">


    <EditText
        android:id="@+id/platenbET"
        android:layout_width="wrap_content"
        android:layout_height="36dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint=" Plate Number"
        android:inputType="number"
        android:textColor="@android:color/white"
        android:textColorHint="@android:color/white"

        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        style="@style/App_EditTextStyle"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="72dp"
        android:text="Check your Speed Tickets in Lebanon"
        android:textColor="@android:color/white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="316dp"
        android:layout_height="101dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/logohomepage" />

    <Spinner
        android:id="@+id/spinner"
        style="@style/Widget.AppCompat.Spinner"
        android:layout_width="215dp"
        android:layout_height="36dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="#d90b0a41"
        android:spinnerMode="dropdown"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/platenbET" />

    <Button
        android:id="@+id/checkBtn"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="92dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/button1"
        android:text="Check Ticket"
        android:textColor="@android:color/background_light"
        android:textColorHighlight="@android:color/background_light"
        android:textCursorDrawable="@android:color/white"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/spinner"
        app:layout_constraintVertical_bias="0.519" />


</android.support.constraint.ConstraintLayout>

In summary, I need help knowing where this extra keyboard (second photo) is coming from and how to remove it.


Solution

  • Try this Use android:imeOptions="actionDone" in your EditText

    <EditText
            android:id="@+id/platenbET"
            android:layout_width="wrap_content"
            android:layout_height="36dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:ems="10"
            android:hint=" Plate Number"
            android:inputType="number"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:imeOptions="actionDone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.503"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView"
            style="@style/App_EditTextStyle"/>