【问题标题】:Android Webview doesn't show keyboard when text edit field got a focus当文本编辑字段获得焦点时,Android Webview 不显示键盘
【发布时间】:2019-04-29 15:02:15
【问题描述】:

我有一个 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"/>

【问题讨论】:

  • 它是否在移动 chrome 中打开?
  • @MarcinOrlowski 它在WebView 开放

标签: android webview google-forms


【解决方案1】:

您是否尝试在 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;
    }
});

【讨论】:

  • 不幸的是这没有帮助
猜你喜欢
  • 2023-04-03
  • 2016-05-20
  • 2014-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-23
  • 1970-01-01
  • 2013-12-13
相关资源
最近更新 更多