Reputation: 361
I want to set the dropdown of an autoCompleteTextView above the input field. Is there any attribute or method around to set the dropdown always on top ?
Thanks in advance
Upvotes: 2
Views: 5894
Reputation: 1550
Try android:dropDownAnchor
. Learn more about this AutoCompleteTextView
Edit
Try setting android:dropDownAnchor
along with android:dropDownHeight,android:dropDownHorizontalOffset, android:dropDownVerticalOffset
to get desired position
<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"/>
Upvotes: 3
Reputation: 82
In your layout
<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 Code
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
Upvotes: -1