Android的软键盘显示在网页流量达 [英] Android soft keyboard showing up on webview

查看:134
本文介绍了Android的软键盘显示在网页流量达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多有关如何在Android的的WebView 显示软键盘的问题。我有一个问题相当相反的。

由于某些原因,软键盘保持在视图内容。我点击任何东西,每次(只是一些文本为例)显示出来。有在视图中没有输入字段,也没有任何的EditText 元素。

使用(与旧版本或者4.4不是一个问题)的Andr​​oid 4.3时,这个问题只存在。

我已经试过大部分我已经找到了解决方案,我可以得到那个东西是用不出现的唯一方式。

 的android:focusableInTouchMode =假

在布局文件。

这会导致其他问题,但 - 现在如果我添加了一个选择字段中的WebView窗口中的HTML文件 - 选择后犯了一个错误产生和焦点不会返回网页视图(所以不能用它了以后这一点)。


  

10月1日至7日:59:49.848:W / InputMethodManagerService(287):窗口已经集中,忽略
  聚焦增益的:com.android.internal.view.IInputMethodClient$Stub$Proxy@41a0b510属性= NULL,标记= android.os.BinderProxy@41771d70



解决方案

找到了解决办法。 pretty怪异之一。我从布局定义删除focusableInTouchMode的事情,在我的WebView内容添加到了JavaScript的:

  document.addEventListener(点击功能(){
  document.activeElement.blur();
});

There are a lot of questions about how to display Soft Keyboard in android WebView. 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. There are no input fields in the view, nor are there any EditText elements.

This problem exists only when using Android 4.3 (not an issue with older versions or with 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).

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

解决方案

Found a solution. Pretty weird one. I removed the focusableInTouchMode thing from the layout definition and added this to JavaScript in my WebView content:

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

这篇关于Android的软键盘显示在网页流量达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆