android - 当文本编辑字段获得焦点时,Android Webview 不显示键盘
问题描述
我有 DialogFragment 和一个 WebView ,它打开了 Google Forms 网页。但是单击文本输入字段时键盘不显示。有什么建议么?原始 Android 8.1 (Nexus 5x)。
WebView webView = binding.webView;
webView.requestFocus(View.FOCUS_DOWN);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(google_form_url);
布局:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data />
<WebView
android:id="@+id/webView"
style="?android:attr/webViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true" />
</layout>
显现:
<activity
android:name="com.keeple.april.Activity2"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize"/>
解决方案
您是否尝试在 requestFocus 下方添加触摸侦听器?
webView.setOnTouchListener(new View.OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
if (!v.hasFocus())
{
v.requestFocus();
}
break;
}
return false;
}
});
推荐阅读
- sensu - 客户端在 1171 秒内没有发送 keepalive (>=180)
- python - Pandas - 仅查看某些列时查找两个数据框之间的异常行
- python - 在 Mayavi 中设置 Nan 颜色
- sql-server - TSQL:在记录序列中查找记录组
- javascript - 如何从树中删除每个对象
- c# - EPPlus:在 Excel 中查找整行是否为空
- android - Android 窗口全屏,没有操作栏
- php - mkdir() 不在网站上创建文件夹
- amazon-elastic-beanstalk - 是否可以打开与 ebs linux 实例的终端会话?
- android - Unity 3D游戏实时更改屏幕方向导致触摸坐标错误