0

I read some threads regarding this issue (this, this, this), with no solution for my problem.

This is fairly a simple WebView component that load a JSON data in a html template. The unique case might be that it is a tab fragment component inside an activity.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:focusableInTouchMode="true">
    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone" />
    <view.BKProgressBar
        android:id="@+id/progressBar"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />
</RelativeLayout>

This is the Java code:

        webView = view.findViewById(R.id.webView);
        progressBar = view.findViewById(R.id.progressBar);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.setVerticalScrollBarEnabled(true);

        webView.setWebViewClient(new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
                webView.setVisibility(View.VISIBLE);
                progressBar.setVisibility(View.GONE);
            }
        });

        progressBar.setVisibility(View.GONE);
        webView.setVisibility(View.VISIBLE);


        webView.addJavascriptInterface(new WebAppInterface(getActivity()), "AndroidNativeWrapper");

        reloadJSON();

The device is Huawei model ATU-L21 running Android 8. Does anybody have the same problem?

Seto
  • 1,234
  • 1
  • 17
  • 33

2 Answers2

0

try this

webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.setVerticalScrollBarEnabled(true);
webView.setHorizontalScrollBarEnabled(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.setWebChromeClient(new WebChromeClient());
khushbu vadi
  • 391
  • 2
  • 10
0

Turns out, it's a one-liner solution in the html template:

html {
    overflow-y:auto;
}

Thanks to my coworker. I suspected this before, but I was reluctant to debug it. I hope it helps someone else.

Seto
  • 1,234
  • 1
  • 17
  • 33