How to properly zoom a WebView together with it's background image? - android

I'm using the following code which only zooms the loadData. How is it possible to zoom the image inside? Thank you in advance!
WebView web = (WebView) findViewById(R.id.myid);
web.loadUrl("file:///android_asset/image.jpg");
web.getSettings().setBuiltInZoomControls(true);
web.setBackgroundColor(0);
web.setVisibility(ImageView.VISIBLE);
web.setBackgroundResource(R.drawable.myimage);

I finally did it by insersting the image.jpg in an html file which took the place of loadUrl().

Related

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);

How to center content in webView Android ?

I'm trying to load image in webView Android. The image size is 320x50 and same for the webView size, but the image is not in center, and I don't understand why.
Can you help me ?
Have you tried:
WebView webView = (WebView) findViewById(R.id.myWebView);
webView.getSettings().setDefaultZoom(ZoomDensity.FAR);

Zoom in webview loading a flash file

This is the WebView I have in my application
webView = (WebView) findViewById(R.id.web);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.setLongClickable(false);
webView.setWebViewClient(wvc);
webView.loadUrl("file://" + path);
The webview is loading a local flash (.swf) file
I've been trying to get create a zoom system that works in the WebView. I've already tried using the setBuiltInZoomControls(true), but when I zoom in, the flash automatically adjusts itself to the WebView's size, making the zoom controls useless.
How can I stop this from happening? (in the flash file or the WebView)
Thanks in advance.
The workaround I used to correct this was not to load directly the flash file, but to load an HTML file with a flash object within it.
The pitch zoom doesn't work (when done on/over the flash), but the built-in zoom control from the WebView are correctly working.

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);

How to set android webview zoom to specific height

I am using a Webview to look at a local image with zoom support and all that. Is there any way that I can make the WebView zoom to only fit the height of the image, instead of the width like it does with my current code? Here is what I have:
WebView image = (WebView)findViewById(R.id.map);
image.getSettings().setBuiltInZoomControls(true);
image.getSettings().setLoadWithOverviewMode(true);
image.getSettings().setUseWideViewPort(true);
image.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
image.loadUrl("file:///android_asset/image.png");
Try using the webView Settings
use the webSettings class
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
Check out Set zoom for Webview
Update:
as setDefaultZoom deprecated you need to use another settings

Categories

Resources