У меня есть AutoCompleteTextView внутри DialogFragment:
макет:
<?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
}
}
Когда я набираю «aa» в AutoCompleteTextView, раскрывающийся список открывается, но частично скрыт программной клавиатурой. Элементы, расположенные ниже по списку, не могут быть выбраны. Прокрутка выпадающего списка возможна, но не все элементы можно прокручивать в поле зрения. Нижние элементы всегда остаются скрытыми с помощью программной клавиатуры.
Когда AutoCompleteTextView является частью Activity, а не DialogFragment, все элементы доступны для выбора.
Протестировано с несколькими различными телефонами и Android версии.
Мне кажется, это ошибка при компоновке DialogFragment. Алгоритм макета, похоже, не учитывает ту часть экрана, которая занята программной клавиатурой.
Могу ли я что-нибудь сделать с этим?