19

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>
androniennn
  • 3,117
  • 11
  • 50
  • 107
  • Traditionally WebView's in android support horizontal scrolling by default. Maybe you're disabling it in your code somehow or you're not viewing a page that scrolls horizontally? – bbedward Mar 07 '12 at 13:56
  • @bbedward: please look at my code – androniennn Mar 07 '12 at 14:16

1 Answers1

26

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);
Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139