簡體   English   中英

當文本編輯字段獲得焦點時,Android Webview不顯示鍵盤

[英]Android Webview doesn't show keyboard when text edit field got a focus

我有一個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;
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM