android autocompletetextview hint results hidden under keyboard

Viewed 10730

I have 3 autocompletetextview's in which i set its adapter to be an ArrayAdapter<String> with a very simple textview layout.

The autocompletextview hint results are showing, but are under the onscreen keyboard(i can see part of it). how can i make the results show above the autocompletetextview rather than below?

    airline = (AutoCompleteTextView)findViewById(R.id.airline);
    airline.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, AIRLINES_AUTOCOMPLETE_ARRAY));

    departLocation = (AutoCompleteTextView)findViewById(R.id.departLocation);
    departLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));

    arriveLocation = (AutoCompleteTextView)findViewById(R.id.arriveLocation);
    arriveLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
10 Answers

Simply limit the drop-down height.

android:dropDownHeight="200dp"

Then results don't hide by the soft keyboard.

Or else do this

The theory says that android:windowSoftInputMode="adjustPan|adjustResize" should do this but for some reason, it doesn't, so you have to do the same programmatically:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

another quick solution is by using the attribute "android:dropDownAnchor" to anchor the dropdown to some other view on top of screen

If none of the above solutions worked. try this

android:dropDownHeight="match_parent"

If we didn't mention the dropdown height, it would be considered wrap_content. Therefore the item will show behind the soft keyboard.

Related