Search code examples
androidautocompletetextview

DropDownAnchor not working in AutoCompleteTextView


I have an AutoCompleteTextView in my project. It's working, but the dropdown list is showing at the top of the text view instead of bottom. I have the dropDownAnchor set to the text view but it doesn't do anything. I don't know how else to fix it. Any help would be greatly appreciated.

<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">

This is what it looks like:

enter image description here


Solution

  • See image below of two drop down of same hint list. Only difference is i added android:dropDownHeight="180dp"

    in AutoCompleteTextView

    You can not set position of drop down in auto complete Text view. It will take position where it fits. Priority is downwards. In your case upward height is more than downward direction.so if you want always downward then give some height like I told above which is less than the space between keyboard and entering Text View

    enter image description here