I use autoComplete in my project. Here is the usage of autoComplete:
In Code:
val arrayAdapter = context?.let {
ArrayAdapter<String>(
it, // Context
android.R.layout.simple_list_item_1,
autocompleteOptions // Array
)
}
autoCompleteTextView.setAdapter(arrayAdapter)
// Set an item click listener for auto complete text view
autoCompleteTextView.onItemClickListener =
AdapterView.OnItemClickListener { parent, _, position, _ ->
//some logic
}
In XML:
<AutoCompleteTextView
android:id="@+id/actvSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true""
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:completionThreshold="0"
android:dropDownHeight="200dp"
android:layout_gravity="center_vertical" />
My question is there any way to adjust the size of the dropdown list according to the current options displayed in the dropdown?