简体   繁体   English

Android软键盘显示在Webview上

[英]Android soft keyboard showing up on webview

There are a lot of questions about how to display Soft Keyboard in android WebView . 关于如何在android WebView显示Soft Keyboard存在很多问题。 I have a problem quite opposite of that. 我有一个与之完全相反的问题。

For some reason the Soft Keyboard keeps showing up every time I click anything (just some text for example) in the WebView content. 由于某种原因,每次我单击WebView内容中的任何内容(例如,一些文本)时, Soft Keyboard一直显示。 There are no input fields in the view, nor are there any EditText elements. 视图中没有输入字段,也没有任何EditText元素。

This problem exists only when using Android 4.3 (not an issue with older versions or with 4.4). 仅当使用Android 4.3时才存在此问题(旧版本或4.4都不存在)。

I have tried most of the solutions I have found and the only way I can get that thing to not appear is using 我已经尝试了大多数发现的解决方案,并且使该问题不出现的唯一方法是使用

android:focusableInTouchMode="false" 

in the layout file. 在布局文件中。

That causes other problems though - now if I add a select field to the HTML file in WebView window - after selection is made an error is produced and focus does not return to the webview (so can't use it any more after that). 但是,这会导致其他问题-现在,如果我将选择字段添加到WebView窗口中的HTML文件中-做出选择后会产生错误,并且焦点不会返回到Webview(因此之后将无法再使用它)。

01-07 10:59:49.848: W/InputMethodManagerService(287): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41a0b510 attribute=null, token = android.os.BinderProxy@41771d70 01-07 10:59:49.848:W / InputMethodManagerService(287):窗口已经聚焦,忽略了com.android.internal.view.IInputMethodClient$Stub$Proxy@41a0b510 attribute = null,token = android.os的聚焦增益。 BinderProxy @ 41771d70

Found a solution. 找到了解决方案。 Pretty weird one. 挺奇怪的。 I removed the focusableInTouchMode thing from the layout definition and added this to JavaScript in my WebView content: 我从布局定义中删除了focusableInTouchMode并将其添加到WebView内容的JavaScript中:

document.addEventListener('click',function() { 
  document.activeElement.blur(); 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM