how to know when and where a textfield is focused in an android webview? - android

Normally when a native textfield in an android view is focused, the view scrolls automatically to keep the field visible when the virtual keyboard appears. And it's normally the same behaviour when I select a textfield in a webview (so I mean a html text input in the page that loaded in the webview).
But for some reason, it doesn't work in my case. I have a webview that displays a form and when a select a textfield, the view scrolls down to the bottom of the page and the field I selected is no longer visible. What should I check in my app to prevent this to happen? If you need more details, just ask. In this way I can show you directly what you need.
Thanks in advance.
EDIT: on android 4, this is not happening. I encountered the problem on android 2.2 and 2.3.

android:windowSoftInputMode="adjustResize"
Add above tag in your manifest file's activity tag. The activity will be the one which displays webview

Related

keyboard covering webview form in Android app

I have a webview of a form in an android app, but the problem is that when I open up the keyboard to type, it covers the other input fields. for the fields near the top, i can click on to type, but the last field is entirely covered by the keyboard, such that if I lower the keyboard and click on the input field in the webview, the keyboard will cover the field (I can type in it, but not see what I am typing)
does anyone have thoughts/guidance/resources on how to approach this problem?
alternatively, does anyone know how I could do something like the following: when I click a input field in a webview, for the keyboard to show right below the field for each field on the page.
I've seen some resources around adjustPan and adjustResize in windowSoftInputMode, but that didn't seem to solve it for me, though I could still be wrong. I am working with an sdk that gets the webview up, so there could be indirection that I am missing.

Android WebView disable keyboard predictions

I've been scouring the web for hours now looking for answer to these two questions, to no avail.
How do I disable all keyboard auto-complete suggestions within an app/activity/WebView? Most answers focus on scenarios that include an EditText, but in my scenario, there is just a WebView with input fields.
In the scenario described above, how do I keep the keyboard open all the time I am in the activity containing the WebView? Pressing the "Done" button on the keyboard makes the text field lose focus and the keyboard collapses.
Thanks!
For your first requirement
android:windowSoftInputMode="stateVisible" // Add this Manifest section
For your second requirement
webviewOBJ.clearFormData();
webviewOBJ.getSettings().setSaveFormData(false);
setSaveFormData
Sets whether the WebView should save form data. In Android O, the
platform has implemented a fully functional Autofill feature to store
form data. Therefore, the Webview form data save feature is disabled.
You should read Android Webview private browsing
Add this line in manifests file inside your web view activity
android:windowSoftInputMode="stateVisible"

Is there anyway using html5 to force android/ios virtual keyboard to be shown

I have some html forms that when they get rendered I would like the keyboard to appear without the user having to touch the field first. I have tried using click and focus neither brings up the keyboard.
For what its worth I am using angular.
I do not believe this is possible with out a very kludgy work around. You might be able to have a hidden text field that it set to focus, which would bring up the keyboard and then manually set focus on other items in the view when needed. However this might cause some issues and you might be able to see the cursor in the hidden text field, among other issues. Why do you need the keyboard to be displayed without a focus on some field?

Android WebView Font Face Not Initially Rendering

I'm working on a mobile web app. The issue is apparent in some Android's (I think only 2.3.x phones).
There is a label and an input submit button on a page. Both are styled to have the same font face (TradeGothic, created by a #font-face style).
The label text always renders correctly however the button text never shows up the first time the page is visited.
So if you go to the page and either click on the button or go back and then forward (to the page in question) then the button text shows up fine.
I've tried resetting the value of the input button using jquery. I've also tried setting it's html and text however there are no changes.
What else can I try? (Besides losing the font.)
Slightly hacky option, could you not use an image for the button which is using the desired font?
I fixed the issue by loading a dummy html page in the webview (in the background) while the app is starting up.
The dummy page consists of only the html for the button and it loads the same css file.

Text Input on android phone is not in view when the keyboard for webview comes up?

I have a webview on an android phone that is a registration form and it contains some fields such as first name, last name, user name, password, etc... When focus on the first name input field for example, the keyboard pops up, but the input goes out of view, it still has focus though. Is there a way to keep it in view or is this a bug?
This seems to be a problem common to Android applications. The application does not scroll the view such that the input field under focus is visible when the soft keyboard appears. There might be a solution, but it is something you'd have to implement and not a bug (per se).
I found this answer here :
https://stackoverflow.com/a/5097539/1498996
Add this to your activity tag in the AndroidManifest.xml:
<activity android:windowSoftInputMode="adjustNothing"
//other flags
/>
It worked for me.

Categories

Resources