在上面设置下拉列表 Android 自动完成文本视图

Set dropdown above for Android Auto complete textview

我想在输入字段上方设置 autoCompleteTextView 的下拉菜单。是否有任何属性或方法可以将下拉列表始终设置在顶部?

提前致谢

在你的布局中

<AutoCompleteTextView
        android:id="@+id/autoCompleteTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView"
        android:layout_marginLeft="36dp"
        android:layout_marginTop="17dp"
        android:ems="10"
        android:text="">

Java代码

ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (this, android.R.layout.select_dialog_item, fruits);
        //Getting the instance of AutoCompleteTextView
        AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
        actv.setThreshold(1);//will start working from first character
        actv.setAdapter(adapter);//setting the adapter data into the 

尝试android:dropDownAnchor。详细了解此 AutoCompleteTextView

编辑

尝试设置 android:dropDownAnchorandroid:dropDownHeight,android:dropDownHorizontalOffset, android:dropDownVerticalOffset 以获得所需的位置

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:dropDownAnchor="@id/textView"
    android:dropDownHeight="100dp"
    android:dropDownWidth="200dp"
    android:text=""
    android:dropDownVerticalOffset="120dp"
    android:dropDownHorizontalOffset="0dp"/>