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.
Related
On some Android Oreo devices, when I load an url on webview for the first time, the URL page loads properly. However, when I load the URL again, the page is zoomed out. On devices lower than android oreo, the page loads properly for all devices.
Also, when you kill the app on the background and load again, the URL loads properly. On the second and succeeding tries, it shows the zoomed out version again. I attached the images of loaded URL below
Below is the correct loading of webpage on the webview
Below is the small display of webpage on webview webview
Android XML Code:
<WebView
android:id="#+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Java Code:
private WebView mWebView;
mWebView = (WebView) view.findViewById(R.id.content_view);
mWebView.loadUrl("https://policies.google.com/");
URL: https://policies.google.com/
Take note that this happen in other URLs too. https://policies.google.com/ is just an example
It works on the following:
Huawei nova 2i RNE-L22, Android 8.0.0
It DOES NOT work on the following
Android 8.1.0; Pixel 2
Android 8.0.0; Samsung SM-G950FD
Android 8.0.1; Huawei P20 EML-L29
Any suggestions or reasons as why this happens? How to fix this?
Thanks in advance.
if you have problems related to zoom in webview
try to add zoom in and zoom out functions to your webview
you can add these lines to your java code, to implement zooming in and out
mWebView.loadUrl(url);
//code for zooming functions
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
//for javascript
webView.getSettings().setJavaScriptEnabled(true);
After asking google team about this issue,
the said that it's probably some viewport layout settings. Webview has some unfortunate defaults due to legacy issues.,
Adding webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); fixed the issue.
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
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);
Everytime I load a page in the webview, the webview tries to squash the web page into a small frame. However, in the standard android browser, it loads the page at the full size and allows the user to zoom in however much they decide.
Is there anyway to make a webview load a page like the default web browser?
Something like this:
WebView wv;
WebSettings webSettings = wv.getSettings();
webSettings.setBuiltInZoomControls(true); //when you define webview settings just add this to enable zoom
wv.setInitialScale(1); //lets set initial zoom to 1% to see whole page when it loads