Android WebView disable keyboard predictions

杀马特。学长 韩版系。学妹 提交于 2020-01-06 04:45:09

问题


I've been scouring the web for hours now looking for answer to these two questions, to no avail.

  1. 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.
  2. 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!


回答1:


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




回答2:


Add this line in manifests file inside your web view activity

android:windowSoftInputMode="stateVisible"


来源:https://stackoverflow.com/questions/45206289/android-webview-disable-keyboard-predictions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!