Possible Duplicate:
Android Webview - Webpage should fit the device screen
I want to render a webpage in android's webview. Currently, I can display a webpage but how to make it fit within the screen? I referred to: Android Webview - Webpage should fit the device screen but didn't find a solution there.
Thanks!!
* Open the Internet/Browser app. * Tap the menu button and choose Settings from the list. * Tap on the option Advanced. * Find the Auto-fit pages – Format Web pages to fit the screen option and make sure that this is checked.
getSettings(). setBuiltInZoomControls(true); per this answer to default my view to zoomed out and to be able to pinch-to-zoom.
The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.
The only way that works for me was this way:
webView = (WebView) findViewById(R.id.noticiasWebView);
webView.setInitialScale(1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
webView.loadUrl("http://www.resource.com.br/");
I am working on Android 2.1 because of the kind of devices from the company. But I fixed my problem using the part of informations from each one.
My solution was different. I made a webpage big enough so it would then get zoomed out. And in the webview settings i put the following:
WebView webview = new WebView(this);
//webview.setInitialScale(100); No need for this one
WebSettings settings = webview.getSettings();
settings.setBuiltInZoomControls(false);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setSupportMultipleWindows(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setLoadsImagesAutomatically(true);
settings.setLightTouchEnabled(true);
settings.setDomStorageEnabled(true);
settings.setLoadWithOverviewMode(true);
Be sure to import the following: import android.webkit.WebSettings.ZoomDensity;
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