Android soft keyboard does not pan web view

The original problem I'm struggling with is more complex, but for research purposes, I simplified the test case as follows:

  • Single full-screen activity
  • A programmatically created web view that takes up about half of the horizontal space of the screen, 90% of the vertical space and is added to the root view via the onCreate call:

ViewGroup parent = (ViewGroup) getWindow().getDecorView().getRootView(); parent.addView(myWebView);

  • Web browsing opens on google.com via:

loadUrl("http://google.com")

  • AndroidManifest.xml has the following property:

"android:windowSoftInputMode="adjustPan"

When you click on the search box on the google page, a keyboard appears, but the web view itself does not move, since the PanPan parameter must be specified. The main action also has its own text box, which, when clicked, moves the entire layout (including the web view) up as expected.

The behavior is present on 4.2.2 on both the Nexus 7 and Galaxy Nexus.

So, the question is how can I adjust the windowSoftInputMode adjustPan property to correctly apply to an instance of the web view, so that when the soft keyboard is displayed, the entire web view is shifted to the vertical space occupied by the keyboard.

Before I go down the path to manually manipulate the layout in onMeasure, I want to see if there is a compatible / better way to handle this. Obviously, the browser is handling this situation correctly, so it’s not sure why the web view cannot handle it.

It should be noted that creating a full-screen web view or a separate action is not possible due to the existing architecture, which I cannot change.

+7
android webview keyboard textfield ime
source share
1 answer

If we use full screen without an action bar, the Resize setting will not work. See this topic for more information.

adjustPan does not prevent EditText keyboard from closing
0
source share

All Articles