Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android soft keyboard pushing views

i'm developing a soft keyboard for an android and I faced a problem which I could not solve. The problem is that when I open a keyboard it moves other views incorrectly (see the picture, my keyboard on the left).

This is how my problem looks like

I have tried multiple solutions that I found on stackoverflow or somewhere else, but they didn't work for me.

I've tried:

android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="stateHidden|adjustPan"
android:windowSoftInputMode="adjustResize|stateVisible|stateAlwaysHidden"

but it didn't change the behavior you see on the screenshot.

So, please help me to solve this problem.

Ps. I know that there are many similar questions where "adjustResize" or "stateHidden|adjustPan" is offered, but it doesn't work for me.

P.p.s screenshot is taken in android 6.0.1.

Thanks.

like image 747
Fedor Tsyganov Avatar asked Jul 18 '26 05:07

Fedor Tsyganov


1 Answers

I finally found an answer to my question. You need to use this code in your class that extends InputMethodService:

@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
     super.onComputeInsets(outInsets);
     if (!isFullscreenMode()) {
        outInsets.contentTopInsets = outInsets.visibleTopInsets;
     }
}
like image 112
Fedor Tsyganov Avatar answered Jul 20 '26 19:07

Fedor Tsyganov



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!