I followed the AutoCompleteTextView tutorial exactly. The layout gets wrong when a soft keyboard is involved.
After tapping inside the dropdown (to select or scroll), the layout is broken:
I tried various combinations of attributes on the AutoCompleteTextView but none seems to work. I also tried setting windowSoftInputMode. The dropdown always pops up above the textbox, and stays there forever.
In landscape orientation, the layout is OK:
Is the standard autocomplete useless? Should I use a different one / write my own?
The code I used is the following:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Country" />
<AutoCompleteTextView android:id="@+id/autocomplete_country"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
textView.setAdapter(adapter);
}