DropDownAnchor在AutoCompleteTextView中不起作用

问题描述

我的项目中有一个AutoCompleteTextView。它正在工作,但是下拉列表显示在文本视图的顶部而不是底部。我将dropDownAnchor设置为文本视图,但是它什么也没做。我不知道该如何解决。任何帮助将不胜感激。

<AutoCompleteTextView
        android:id="@+id/tagsTextView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="8dp"
        android:backgroundTint="@color/darkGray"
        android:completionThreshold="2"
        android:dropDownAnchor="@+id/tagsTextView"
        android:hint="Enter Tag"
        android:textCursorDrawable="@drawable/autocomplete_cursor_color"
        app:layout_constraintEnd_toStartOf="@id/addButton"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tagsLayout">

外观如下:

enter image description here

解决方法

请参见以下相同提示列表的两个下拉列表中的图像。 我只加了区别 android:dropDownHeight =“ 180dp”

AutoCompleteTextView

您无法在自动完成文本视图中设置下拉菜单的位置。它将放置在合适的位置。优先顺序是向下的。在您的情况下,向上的高度大于向下的方向。因此,如果您要始终向下,则像我上面所说的那样设置一些高度,该高度小于键盘和进入“文本视图”之间的空间

enter image description here