Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView Scrollable

I'm making a browser based on android WebView class. I want to enable both horizontal and vertical scrolls on the webview and want it to behave exactly like the android browser? Is there any setting for that in the manifest file or shall i override the default webviewclient class.

like image 632
Sultan Saadat Avatar asked Jun 06 '11 14:06

Sultan Saadat


1 Answers

The WebView documentation says:

By default, a WebView provides no browser-like widgets

It also says:

A WebView has several customization points where you can add your own behavior. These are:

...

Creating and setting a WebViewClient subclass. It will be called when things happen that impact the rendering of the content, eg, errors or form submissions. You can also intercept URL loading here.

Which suggests WebViewClient has nothing to do with the scroll bars, since they're not content.

I was going to suggest putting a WebView inside of a ScrollView, but looking at this link it seems WebView's default behaviour is to include scroll bars, which makes sense since a lot of scrollbar functionality is defined in the high level View class. Have you tried just making a regular WebView? If so, have you tried adding the following in your java code?

WebView v = (WebView) findViewById(R.id.webview); 
v.setVerticalScrollBarEnabled(true);
v.setHorizontalScrollBarEnabled(true);
like image 74
CL22 Avatar answered Sep 28 '22 06:09

CL22