webview弹出窗口中的内容隐藏在键盘后面(特殊情况请阅读)

时间:2018-11-29 21:37:55

标签: android webview kotlin android-webview android-scrollview

我有一个独特的Webview问题(与在线其他问题不同,因此请先将其标记为重复阅读) 因此,我有一个可正常滚动的webview,但是当我单击webview中的按钮时,会弹出一个对话框,要求输入姓名,电子邮件等,但是,一旦我开始输入我的姓名等,就会弹出键盘,将内容隐藏在弹出窗口的第三行是我的情况下的电子邮件。当背景滚动正常时,我无法在此webview(弹出窗口)中滚动。有什么办法可以解决这个问题?我在网上尝试了Adjustresize和其他几种方法,但是到目前为止还没有运气。这是我的代码:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorWhite"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.Redesign">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/toolbar_and_status_bar_height"
            android:background="@color/toolbar_background"
            android:paddingTop="@dimen/status_bar_height"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.AppBarLayout>

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

在这里输入相同的kt文件:

   webView.settings.javaScriptEnabled = true
    webView.settings.javaScriptCanOpenWindowsAutomatically = true
    webView.settings.setAppCacheEnabled(true)
    webView.settings.cacheMode = WebSettings.LOAD_DEFAULT
    webView.settings.allowFileAccess = true
    webView.settings.allowContentAccess = true
    webView.settings.allowFileAccessFromFileURLs = true
    webView.settings.allowUniversalAccessFromFileURLs = true
    webView.settings.domStorageEnabled = true

    webView.webChromeClient = WebChromeClient()
    webView.webViewClient = object : WebViewClient() {
        override fun onPageFinished(view: WebView?, url: String?) {
            hideProgress()
            super.onPageFinished(view, url)
        }

        override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
            hideProgress()
            super.onReceivedError(view, request, error)
        }

        override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
            if (request?.url?.toString()?.startsWith("mailto:") == true) {
                val intent = Intent(Intent.ACTION_VIEW, request.url)
                startActivity(intent)
                return true
            }
            if (request?.url?.toString()?.startsWith("tel:") == true) {
                startActivity(Intent(Intent.ACTION_DIAL, request.url))
                return true
            }

            return super.shouldOverrideUrlLoading(view, request)
        }
    }



        webView.loadUrl(urlToOpen)


Any ideas how to go ab out it?

谢谢!

0 个答案:

没有答案