Search code examples
androiddropdownandroid-softkeyboardautocompletetextview

AutoCompleteTextView suggestion hides under keyboard when there is only one suggestion


I am using an AutoCompleteTextView in my Android project, pretty much everything is working as expected except for the following:

When I only have a single suggestion to display, this suggestion is hidden under the soft keyboard. But when I have more than one suggestion then they appear above the soft keyboard (but not above my AutoCompleteTextView sadly) and I can see all of them and scroll through them if there are many.

I have tried modifying android:dropDownHeight but without success. I have also tried setting android:windowSoftInputMode="adjustResize|adjustPan" and it works (I can see all suggestions even if there is only one) but then it messes with my layout and distorts everything that is displayed.

Is it possible to force the dropdown suggestions to always display above the AutoCompleteTextView? Otherwise how could I go about solving this?

Here is the XML for the AutoCompleteTextView :

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:maxLines="1"
    android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
    android:ems="10"
    android:inputType="text"
    android:fontFamily="@font/poppins_bold"
    android:textColor="@color/colorPrimary"
    android:background="@drawable/backwithborder"
    android:padding="8dp"
    android:paddingLeft="12dp"
    android:paddingStart="12dp"
    android:maxLength="25"
    android:dropDownAnchor="@id/givePointsToText"
    android:layout_toRightOf="@id/pointsSpinner"
    android:layout_toEndOf="@id/pointsSpinner"
    android:layout_toLeftOf="@id/givePointsButton"
    android:layout_toStartOf="@id/givePointsButton"
    android:layout_centerVertical="true"
    android:dropDownWidth="match_parent"/>


Solution

  • I "fixed" my problem by moving the AutoCompleteTextView to the top of the screen, that way the suggestion dropdown is only on one side and there is room for both the dropdown and the soft keyboard.

    Ugly solution but that's the only thing I could do to solve my problem.