AdjustResize does not work after rejecting the keyboard by pressing an external keyboard

I have a WebView (inside a snippet in ViewPager with SlidingTabLayout).

When using the WebView type, I want the layout to change to make sure the input is visible.

When I press text input in WebView, an on-screen keyboard appears and the layout size changes. I can enter my text and send using the return button to the soft keyboard or cancel the input using the "Back" button. After that, the keyboard disappears, and the layout changes back. Correct the behavior of AdjustResize .

However, dropping the keyboard, going beyond the Softkeyboard (for example, when entering a query in Google and pressing the search button in WebView), the keyboard hides, and it takes about 2-3 seconds to change the layout (leaving an empty space for 2-3 seconds at the bottom my layout). After that, when choosing textinput, the keyboard overlays the WebView (adjustPan).

How can I make sure that when you turn off the keyboard by pressing WebView, the behavior of AdjustResize .

I tried reinstalling AdjustResize (e.g. from onTouch), but this has no effect:

 this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

I also tried the following solution , but this does not give any changes.

Also, I think this is probably not an issue of attention (since the keyboard appears and the webview responds). And I set focus from my view:

  webView.setFocusable(true); webView.setFocusableInTouchMode(true); 
+6
source share
1 answer

It turned out that when you perform layout translations in WebView or if the WebView layout changes indirectly (for example, when you resize an element above the WebView in RelativeLayout, which also causes the WeView to resize), showing and hiding the keyboard can cause strange behavior:

  • AdjustResize behavior may be lost (as indicated in the question)
  • Resizing WebView after the keyboard may take longer than usual.
  • WebView performance degrades.

For me, this problem is resolved to prevent layout changes in WebView in any way (reloading the layout during rotation does not seem to cause this). In my case, I showed and hid the toolbar, which caused the web screen to resize (and fill the screen).

0
source

All Articles