2

I have a unique case of webview issue (unlike any other issue online, so please before marking it as duplicate read it out) So, I have a webview which scrolls fine but as soon as I click on a button inside webview a popup comes up asking to enter name, email etc., but as soon as I start entering my name etc keyboard pops up hiding the content on the third line of the popup which is the email in my case. I am unable to scroll within this webview (popup) while the background scrolls fine. Any way I can fix this issue? I tried adjustresize and several other approaches online but no luck so far. Here's my code:

 <?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>

Heres my kt file for the same:

   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?

Thanks in advance!

  • Can you post a full layout XML that hosts your ``? – Aaron Nov 29 '18 at 21:43
  • sure,just edited my question with layout –  Nov 29 '18 at 21:48
  • Curious, have you tried changing your `WebView` height to `match_parent`? – Aaron Nov 29 '18 at 21:55
  • yup, thats what it was initially, fixed in my question. wrap_content was a test run when all else failed –  Nov 29 '18 at 21:56
  • Ouch, I could be wrong but it feels like this can only be fixed in the web or javascript itself. – Aaron Nov 29 '18 at 22:02
  • they fixed it in the chromeview, it seems to scroll fine in chrome now, but still doesnt work for me :( –  Nov 29 '18 at 22:04
  • It does sound like rendering issue, maybe you just need a chrome-like engine or third-party web view to help you with the issue. – Aaron Nov 29 '18 at 22:10
  • are there any examples online on how to achieve that? why cant we do it with chrome client itself? –  Nov 29 '18 at 22:11
  • I'm not too sure, but I hope this could help you: https://stackoverflow.com/questions/14537083/use-chrome-as-render-engine-for-android-webview – Aaron Nov 29 '18 at 22:14
  • thanks! will try it out. also on a different note, any idea how to go about this : https://stackoverflow.com/questions/53511227/how-to-avoid-memory-leaks-due-to-custom-static-handler-class?noredirect=1#comment93900039_53511227 –  Nov 29 '18 at 22:15

0 Answers0