Using android webview, whenever I dismiss the keyboard it either slides the view up or down. Going through similar issues on SO, I tried using following 2 individually:
android:windowSoftInputMode="adjustPan" - This does prevent sliding of the webview, but now whenever keyboard is up, some of my UI elements are under the keyboard which prevents user from typing/interacting with those elements hidden under the keyboard. I tried adding a scroll to the webview, but scroll doesn't show up with this option. It works fine, if I don't add this property.
android:windowSoftInputMode="adjustResize" - The issue still remains if I use this property.
Layout width and height on my webview is fill_parent.
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Could anything else help me here?
Related
I have a WebView (within a Fragment within a ViewPager with SlidingTabLayout).
When using the WebView to type, I want the layout to resize to make sure the input is visible.
When I click a text input in the WebView, the softkeyboard appears and the layout resizes. I'm able to enter my text and submit using the softkeyboard's return button or cancel input using the back button. After this, the keyboard disappears and the layout resizes back. Correct AdjustResize behavior.
However, when dismissing the keyboard by clicking outside the Softkeyboard (e.g. when entering a query in Google and pressing the Search button in the WebView) the keyboards hides and it takes about 2-3 seconds for the layout to resize (leaving a blank space for 2-3 seconds at the bottom of my layout). After that, when selecting the textinput, the keyboard overlays the WebView (adjustPan).
How can I make sure that when dismissing the keyboard by pressing the WebView, adjustResize behavior is maintained.
I've tried re-setting AdjustResize (e.g. from onTouch) but this has no effect:
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
I've also tried the following solution but this gives no change.
In addition, I've think this is probably not a focus issue (since the keyboard does appear, and the webview does respond). And I do ask focus from my View:
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
It turned out to be that when you perform layout translations on the WebView or if the WebView's layout is changed indirectly (e.g. when resizing an element above the WebView in a RelativeLayout that causes the WeView to also be resized) showing and hiding the keyboard can cause some strange behavior:
AdjustResize behavior can be lost (as indicated in the question)
WebView resize's after keyboard can take longer then normal.
WebView's performance decreases
What solved this issue for me, was to prevent layout changes in the WebView in any way (layout reload upon rotation does not appear to cause this). In my case I was showing and hiding the Toolbar causing the WebView to resize (and fill the screen).
I have an animation between two fragments. The second fragment will bring up a keyboard. As the keyboard will cover parts of the screen, I manually need to but a spacer view in there to adjust my view. Using android:windowSoftInputMode="adjustResize" will result in my transition-animation to be super laggy. Using adjustNothing on the other hand will make it smooth.
So is there any way to get the keyboard height without using adjustResize?
EDIT:
My question is different to f.e. Is there any way in android to get the height of virtual keyboard of device as I can't add adjustResize
Currently, when an EditText comes into focus and the keyboard comes up, the keyboard covers the form layout for a second, then the layout container resizes to expose the form, as illustrated below.
I'd like the layout to resize smoothly as the keyboard rises up. Is this possible?
Add this in your in the manifest:
android:windowSoftInputMode="adjustResize|stateVisible"
In my Android application running in a XOOM device, when I click in an Edittext the keyboard opens and hides the Actionbar. I don't want this to happen, how can I solve this? This is done by the Google Contacts app for the tablet for example.
EDIT:
I have several edittexts in which the user needs fo fill. At first, when the user clicked on one edittext on the bottom, the keyboard showed up and hide the edittext in which the user was typing, so he couldn't see what he was typing. I found it really bad, and to solve it I just added to the manifest: android:windowSoftInputMode="stateVisible|adjustPan"
But after that, now the screen adjust itselfs and hides the action bar.
The Google Contacts app does the same, but it magically doesn't hide the Action bar. How do they do it?
Use adjustResize instead of adjustPan. The framework will always try to keep the focused element on-screen by scrolling any parent views if necessary.
If your EditText field is not nested in some sort of scrolling container such as a ScrollView then your layout may be too tall to completely display when the keyboard resizes your activity. Try wrapping your form's layout in a ScrollView. This will also allow your app's content to scroll if it is running on a smaller screen device where it may have similar issues.
My android application is a webview, and in first page there are 5 editboxes. When i enter some data in editbox the last editbox is hidden by keyboard. So i enclosed webview within a scrollview. But the scrolling is happening only on the first page but not on all the other pages. Is it possible to scroll screen up only if keyboard is hiding some text in webview?
Meanwhile i tried using the window attribute windowSoftInputMode="adjustResize" but still i am getting the same problem. Any Ideas on how to make this working?
-Regards,
Ron..
This could be the consequence of http://code.google.com/p/android/issues/detail?id=5497. Looks like adjustResize should work if you created your layout correctly, but it will not if your app is in fullscreen mode (i.e. the Android status bar is not displayed). If your app runs in fullscreen mode, try the 'normal' mode for a change and see if the webview adjusts its size correctly when the keyboard is displayed.