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.
android webview keyboard textfield ime
dizzymonkey
source share