Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView won't scroll in Android 2.x

I have a problem with the WebView. I am opening a Webpage in this WebView and it won't scroll in Android 2.x, but it will scroll in Android 3.x+.

Any Idea what can I do to fix that?

This is the configuration i use for this WebView:

wView = (WebView) findViewById(R.id.webView1);
wView.getSettings().setJavaScriptEnabled(true);
wView.setHorizontalScrollBarEnabled(true);

And in the Layout:

<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>
like image 343
Styler2go Avatar asked Jun 11 '13 19:06

Styler2go


2 Answers

Something in the css or javascript of that site is not supported by older Android browsers, it's not related to your code.

It's a little too broad to answer definitively - you'll need to test your site for compliance on different browsers. If you are using any specific libraries on your site you'll need to check their compatability.

Here are some links that may help:

  • http://jquerymobile.com/gbs/
  • http://mobilehtml5.org/
like image 51
Ken Wolf Avatar answered Oct 19 '22 11:10

Ken Wolf


In case if you still have problem

    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");

in case if you want to show ProgressBar while the page is still loading use

     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);

            }

        });

hope this helps...

like image 20
ashish.n Avatar answered Oct 19 '22 10:10

ashish.n