Search code examples
androidscrollandroid-softkeyboardautocompletetextview

Cannot scroll dropdown list of AutoCompleteTextView on Android


I have an AutoCompleteTextViewon an AlertDialog. The dropdown list with the suggestions gets partly covert by the keyboard (see screenshot). The result is that I cannot scroll the list.

enter image description here

I already managed to move the dialog to the top of the screen to get more space. When I set android:dropDownHeight to a small value like 150dp the dropdown list is not covert by the keyboard anymore and scrolling works just fine but setting dropDownHeight to a fix value doesn't seem to be a good solution. I want to avoid using "magic numbers" because otherwise I have no guarantee that it will work on all screens.

How can I solve this?


Solution

  • I finally got it working. This line of code did it for me. This way the dropdown list is always fitting with the keyboard.

    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);