Android: Unable to zoom in/out webview for mobile site - android

I cannot seem to get the Android webview to zoom in or out for mobile sites like:
http://m.bbc.co.uk
The webpage just comes out in a single column.
I tried:
I have tried different permutations (true/false) with
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
I have also tried to
WebView.getSettings().setSupportZoom(true);
WebView.getSettings().setBuiltInZoomControls(true);
but it is still not working for me.

have you tried setBuiltInZoomControls
WebView.getSettings().setBuiltInZoomControls(true);

Related

Setting WebView initial zoom out to a particular value

I had added a few images in webview and also have the zooming feature. but initially the webview is so small that a person cannot read the data of the images until he zooms to read it. so I just want to know how can I set webview initial zoom feature to a particular value
webView = (WebView) findViewById(R.id.phy_law_web);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.loadUrl("file:///android_asset/mathscribe/Analyticgeometry.html");
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);

Zoom image in Webview

I have an image and other elements (div, titles etc.) in my webview and i need only the image to zoom on click, like picture in gallery. Something like in this tutorial. but in webview. I only found, how to zoom whole webview.
You can use this.
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("file:///android_asset/images/yourimage.png");
webview.getSettings().setSupportZoom(true);
webview.getSettings().setBuiltInZoomControls(true);

Android WebView for long images

I'm using WebView as an image viewer in my android application.
The image size is 750X3500 and I need to view the whole image, i.e. I want the maximum zoom out in order the image fit the screen.
It seems to me like impossible mission so far :(
Here is my WebView initialization code:
WebSettings webSettings = mWebView.getSettings();
webSettings.setLoadsImagesAutomatically(true);
webSettings.setSupportZoom(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDefaultZoom(ZoomDensity.FAR);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setJavaScriptEnabled(true);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
And here is a sample image:
http://linkpeek.com/m/vault/c/8/3/c835da21e9d3bd65359d024d0feff30f4eb77cacccf6e477bc9fbb52848984cf.png
Any idea guys?
Thanks.
If you use an HTML page to load the image, then you can use "viewport" HTML meta to control how it displays and zooms.

Is a difference between Chrome and HTML Viewer?

I have an HTML page which I downloaded (save as) in my computer. I loaded the same in the android asset folder and in the webview, i was trying to load the saved HTML page. The HTML page is not fitting in the webview properly. I used the following code:
WebView webView = new WebView(this);
setContentView(webView);
//Enable Java scripts
// webView.getSettings().setJavaScriptEnabled(true);
// webView.setInitialScale(100);
//webView.getSettings().setDefaultZoom(ZoomDensity.FAR);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
//webview.setInitialScale(100); No need for this one
WebSettings settings = webView.getSettings();
settings.setBuiltInZoomControls(false);
Now, I had referred many stackoverflow discussions but, none of them helped. The width of the web page is fitting, however, the height is not. There are lots of blank spaces below the page which i loaded. The layout xml is as below:
<WebView
android:id="#+id/web"
android:layout_width="match_parent"
android:layout_height="fill_parent"/>
I tried to call the website directly from chrome in my android device and the web page is brilliantly fit in the screen. But, the same in the web view is not.
I tried to open the saved html page in HTML viewer and the same happens. Whats the difference here? Please can someone help me on how to fit the web page in the view? Why is there a difference ONLY in the height of the page?
Regards,
Hari

Auto Resizing the webpage in WebView

I am trying to load a webpage using a webview
String url = intent.getStringExtra("url");
WebView myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
//webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
//myWebView.loadUrl(url);
myWebView.loadUrl(url);
This is my current code, however the webpage is not resized in any way.
If I load the same webpage using a browser in the emulator, the webpage is resized and shown correctly. Can someone help me?
myWebView.setInitialScale(50); This helps and resizes the webpage however there is still a small part of the webpage on the left missing.
Is this the correct solution:
How to create an android webview that is the same as the android default browser?
Has someone done something different?
It now load the webpage as I want to but then it has too mush white space. The text is all cramped up in 1 column and doesn't spread over the page.
Try below code,
myWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
try this one
myWebView.setInitialScale(1);

Categories

Resources