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>
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:
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With