1

While building a SNS hybrid application, I noticed that the webview gets scrolled nearly twice the distance than the actual gesture distance. This does not happen always, but I could not figure out the condition for this issue. The content of the webview gets extended as I scroll down, so I am suspecting that it is happening when I interact with the webview while the webview itself is loading and the content of the webview is getting extended. The below is the settings of my webview.

ps. once this issue occurs, it does not go away even if you navigate to another page.

    iWebViewClient = new IWebViewClient(onActivity);
    iWebChromeClient = new IWebChromeClient(onActivity, mContainer, webView, pbar);
    webView.setWebViewClient(iWebViewClient);
    webView.setWebChromeClient(iWebChromeClient);
    webView.setVerticalScrollBarEnabled(false);

    // javascript interface
    webView.addJavascriptInterface(new WebViewInterface(onActivity), "ApplicationInterface");

    WebSettings webSettings = webView.getSettings();

    // enable javascript and storage
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // allow new window to open
    webSettings.setSupportMultipleWindows(true);
    webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

    // enable css
    WebView.setWebContentsDebuggingEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    // disable cache
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    // set useragent
    String device = "Android " + Build.VERSION.RELEASE;
    String appVersion = " " + BuildConfig.APPLICATION_ID + "/" + BuildConfig.VERSION_NAME;
    String agentNew = webSettings.getUserAgentString() + appVersion + " (" + device + ")";
    webSettings.setUserAgentString(agentNew);

    if(initUrl != null){
        webView.loadUrl(initUrl);
    }else{
        webView.loadUrl(HostUrls.webSite);
    }

1 Answer 1

1

Turns out this only happens when my device is connected to chrome remote device inspection tool. Once I connected my device to chrome inspection, the scroll speed doubled immediately and vice versa.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.