Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup of AutoCompleteTextView is showing behind keyboard

I have an AutoCompleteTextView in my app, at the bottom of the layout. When user inputs data, suggestion popup with items should appear. All works as expected on Android Samsung device with OS 6.0.1:

enter image description here

But for Android 8.0.0 (LG device and also an emulator 8.1.0), I don't see such popup, I suppose it showing behind keyboard for some reason (Because when I clicked back button nothing happened - popup handled that event, and only on second back click keyboard disappeared):

enter image description here

My AutocompleteTextview:

 <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
  <LinearLayout ...
        <android.support.v7.widget.AutoCompleteTextView

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="16dp"
                android:background="@drawable/thin_square_border"
                android:maxLines="3"
                android:minHeight="60sp"
                android:padding="12dp"
                android:paddingEnd="16dp"
                android:paddingStart="16dp"
                android:textColor="@color/charcoalgray"

                />
       </LinearLayout>

    </ScrollView>

I've tried dropDownAnchor on view above, and android:dropDownHeight="wrap_content" but that didn't help.

like image 817
Lester Avatar asked Nov 16 '25 15:11

Lester


1 Answers

I found this solution that works for me in Oreo and Pie. I added this to my fragment:

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

This seems like a bug introduced in Oreo. Hope this helps for your case.

like image 177
Jonathan Allsop Avatar answered Nov 19 '25 06:11

Jonathan Allsop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!