Soft keyboard hides dropdown of AutoCompleteTextView in DialogFragment

Viewed 86

I have an AutoCompleteTextView inside a DialogFragment:

layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Test Dialog" />

    <AutoCompleteTextView
        android:id="@+id/autoc"
        android:hint="bliblablub"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</LinearLayout>

DialogFragment:

class TestDialog: DialogFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflater.inflate(R.layout.test_dialog, container)
        view.findViewById<AutoCompleteTextView>(R.id.autoc).setAdapter(
            ArrayAdapter(requireContext(), android.R.layout.simple_dropdown_item_1line,
                listOf( "AAOne", "AATwo", "AAThree", "AAFour", "AAFive", "AASix", "AASeven" )))

        return view
    }
}

When I type "aa" in the AutoCompleteTextView, the dropdown opens, but is partly hidden by the soft keyboard. The items further down the list can't be selected. Scrolling the dropdown is possible, but not all items can be scrolled into view. The bottom items always remain hidden by the soft keyboard.

When the AutoCompleteTextView is part of an Activity, instead of a DialogFragment, all items are selectable.

Tested with several different phones and Android versions.

This seems to me to be a bug when layouting a DialogFragment. The layout algorithm seems not to take into consideration the part of the screen that is occupied by the soft keyboard.

Is there anything I can do about this?

0 Answers
Related