Scrolling drop-down menu above keyboard in autocompletetextview

I have an Autocompletetextview dropping a list of sentences, right down to the edge of the soft keyboard.

Then, scrolling through the list of offers: - (in the gingerbread phone), the drop-down menu automatically increases the height by closing the keyboard, which is nice because it shows more objects. - (in the ICS emulator) the drop-down menu does not increase the height above the keyboard.

Is this due to some kind of system property? Is there a way to force the first behavior also in ICS?

+15
android drop-down-menu autocompletetextview
Feb 07 '13 at 12:10
source share
6 answers

Just add android:dropDownHeight="100dp" to the AutoCompleteTextView tag in the layout file, it will work.

+26
Feb 23 '13 at 10:27
source share

Let me explain my little trick to avoid the “pop-up” display behind the keyboard. The trick is in the dropDownAnchor property. The solution is to install an anchor with a view located at the top of the screen, so the menu will leave this position and, therefore, will not be closed by the keyboard. For example:

android:dropDownAnchor="@+id/topview"

I know this is an ugly solution, but this control is too limited.

+1
Dec 02 '13 at 7:34 on
source share

You can also use android:dropDownAnchor="@id/ to bind a dropdown to a view.

+1
Sep 18 '14 at 18:33
source share

You need to do two things. First, set the soft entry mode of this activity in the manifest.

 android:windowSoftInputMode="stateHidden|adjustResize" 

This means that the views are displayed again when the keyboard is displayed. Then set the global layout receiver in your oncreate in the top-level view to calculate the height of the drop-down list when the layout changes. Adjust the height of the drop-down image to be the height of everything below the keyboard, minus some digression if you want.

 v.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { autoCompleteView.setDropDownHeight(view2.getHeight()); } 

If view2 is a view / layout that includes everything below autocomplete.

0
Sep 05 '14 at 2:57 on
source share

Just add getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); to your fragment or activity

0
Nov 02 '16 at 18:54
source share

A simple solution that works fine with all permissions is to use the android:dropDownAnchor with a resource identifier that refers to the toolbar of your activity.

 <my.app.ContactAutoCompleteTextView android:id="@+id/autocomplete_textview" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top" android:dropDownAnchor="@id/appbar" android:inputType="text|textMultiLine|textCapSentences|textAutoCorrect" android:paddingBottom="12dp" android:textColor="@color/text_primary" android:textColorLink="@color/secondary" android:textSize="@dimen/text_medium" /> 
0
Jan 17 '19 at 16:59
source share



All Articles