Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable horizontal scrolling in a webview

In my webview activity, I can scroll the webpage vertically (up and down) but i can't scroll it horizontally (from right to left or from left to right), when I zoom the webpage too, there is still no horizontal scrolling.

Is there any possibility to add this in the webview? Thank you very much.

getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

        mWebView = (WebView) findViewById(R.id.webview);

        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        mWebView.setVerticalScrollBarEnabled(true);



        mWebView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)   
            {
             //Make the bar disappear after URL is loaded, and changes string to Loading...
            MyActivity.setTitle("Loading...");
             MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded

             // Return the app name after finish loading
                if(progress == 100)
                   MyActivity.setTitle(R.string.app_name);
              }
            });
        mWebView.setWebViewClient(new Manipulation());
        mWebView.getSettings().setJavaScriptEnabled(true);

        mWebView.loadUrl(myURL);

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
>
  <WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
  />
</LinearLayout>
like image 554
androniennn Avatar asked Mar 07 '12 13:03

androniennn


1 Answers

Short answer:

Use this

mWebView.getSettings().setUseWideViewPort(true);

Long Answer:

It might be due to any of the below factors

setLoadWithOverviewMode(true) loads the WebView completely zoomed out

setUseWideViewPort(true) makes the Webview have a normal viewport (such as a normal desktop browser), while when false the webview will have a viewport constrained to it's own dimensions (so if the webview is 50px*50px the viewport will be the same size)

OR

Webview.setInitialScale(xx);
like image 121
Vinayak Bevinakatti Avatar answered Oct 23 '22 20:10

Vinayak Bevinakatti