WebView不会在Android 2.x中滚动

Sty*_*2go 8 java android android-webview

我有WebView的问题.我在这个WebView中打开一个网页,它不会在Android 2.x中滚动,但它会在Android 3.x +中滚动.

任何想法我能做些什么来解决这个问题?

这是我用于此WebView的配置:

wView = (WebView) findViewById(R.id.webView1);
wView.getSettings().setJavaScriptEnabled(true);
wView.setHorizontalScrollBarEnabled(true);
Run Code Online (Sandbox Code Playgroud)

在布局中:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00000000"
    tools:context=".MainActivity" 
    android:orientation="vertical">

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="horizontal" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Ken*_*olf 6

旧版Android浏览器不支持该网站的css或javascript中的某些内容,它与您的代码无关.

它有点过于宽泛无法回答 - 您需要在不同的浏览器上测试您的网站是否合规.如果您在网站上使用任何特定的库,则需要检查它们的兼容性.

以下是一些可能有用的链接:


ash*_*h.n 2

如果您仍有问题

    WebView wv = (WebView) v.findViewById(R.id.webview);
    wv.getSettings().setSupportZoom(true);
    wv.getSettings().setBuiltInZoomControls(true);
    wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    WebSettings settings = wv.getSettings();        
    settings.setUseWideViewPort(true);
    settings.setJavaScriptEnabled(true);
    settings.setSupportMultipleWindows(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLoadsImagesAutomatically(true);
    settings.setLightTouchEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setLoadWithOverviewMode(true);
    wv.loadUrl("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)

如果您想在页面仍在加载时显示 ProgressBar,请使用

     ProgressBar pb = (ProgressBar).findViewById(R.id.webview_progressBar1);

     wv.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return super.shouldOverrideUrlLoading(view, url);
            }

            @Override
            public void onPageFinished(WebView view, String url) {

                super.onPageFinished(view, url);

                pb.setVisibility(View.INVISIBLE);

            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {

                super.onPageStarted(view, url, favicon);

                pb.setVisibility(View.VISIBLE);

            }

        });
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助...