Keyboard covers edittext and webview in Lollipop O

2019-02-20 07:11发布

问题:

I do understand that similar issues have been reported here but mine is somewhat different.

I have recently upgraded the com.android.support:appcompat-v7 to v21 and com.android.support:support-v4 to v19. Everything seemed normal on a pre-lollipop device but when I started to test the device on Android L, two issues appeared:

  1. The softkeyboard was covering EditText
  2. In the webview, system wasn't resizing, pushing the form-fields to the top as it normally should, rather did on pre-lollipop devices.

I read various articles and added the following line to my AndroidManifest.xml file: android:windowSoftInputMode="adjustPan". It did push the edittextfields on top of the keyboard removing the toolbar from the view however it did not resize the view in webview and still covered the form fields at the bottom.

And after the changes, the app on pre-lollipop devices is malfunctioning in the same fashion as well.

Any help will be very much appreciated.

Extract from android-manifest:

<activity ..... android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan"> ... </activity>

I am using the Theme.AppCompat.Light.NoActionBar theme for my app.

回答1:

Incase anyone lands here facing the same issue, the behavior occurs because "they" (Google) have changed the behavior of adjustPan moving forward from Android L.

To fix the issue, I am using a keyboard util in the library as indicated here.

A note from the developer is that this fix is to be used only in fragment/activity becaues this uses a GlobalLayoutListener which lowers the frameRate a bit but this is the only option to get it working