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);
Related
I have a web view and when it is loading URL, it is already zoomed in with some percentage. i.e. user has to scroll horizontally to see the entire content. I want to load the web page with minimum zooming size. i.e. user cannot be zoom out anymore at the time of loading. I tried below, but it is showing the entire page in the web view at once. ultimately I want to fit the web page horizontally.
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
Just use setMinimumFontSize and setUseWideViewPort(true) like below. (Y)
WebView wv = (WebView) findViewById(R.id.webview1);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setMinimumFontSize(35);
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.
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);
in my app i am trying to load a webpage. The webpage contains an image. I want the image to be exactly within the android device screen size. I want the image to be fitted to the evice.
In the web contents we have added the view port tag. I have loaded the URL in default browser of the device,the web page looked to be fitted in 2.1 but in 2.2 version the image seems to be very large. So i loaded the URL in a web view as follows
webView = (WebView)findViewById(R.id.webView1);
WebSettings webSettings = webView.getSettings();
webSettings.setUseWideViewPort(true);
webView.setInitialScale(30);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://xxxxxxxxxxx/get_ban/3");
Now the image is looking good in 2.2 version and in 2.1 it looks very small.
I want the image to be fitted to the screen size common for all the os version, how to do this......
try to use this
setLoadWithOverviewMode(true);
Is it the effect?
Try to use it with
setUseWideViewPort(true);
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().