我想在输入字段上方设置autoCompleteTextView的下拉列表。是否有任何属性或方法可以始终将下拉菜单设置在顶部?
预先感谢
答案 0 :(得分:1)
尝试android:dropDownAnchor
。了解有关此AutoCompleteTextView
修改
尝试将android:dropDownAnchor
和android: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"/>
答案 1 :(得分:0)
在您的布局中
<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