I am using web view to load HTML page which as background image (827 x 1102), I trying to wrap the content within the given height and width of the webView and I don't want to scroll the content at initial stage by exploring regarding this I came to know about below lines of code
mwebview.getSettings().setLoadWithOverviewMode(true);
mwebview.getSettings().setUseWideViewPort(true);
The above code is working fine on 2.2, 2.3.3 but it is adding extra space on 3.0 and higher version, you can check the attached images on different version.
I even tried by appending
<head><meta name=viewport content=target-densitydpi=device-dpi/></head>
In html file but no luck.
Motorla Xoom 3.0
Samsugn Tab 2.3.3
Any help will be appreciated
Thank you in Advance
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'm trying to make this fake app using a fullscreen webview. I made the web pages using the browser but using the webview everything is huge.
i tried the viewport meta, the setUseWideViewPort command, but it doesn't help.
I almost fixed that using:
webSettings.setTextZoom(30);
But the pictures and element sizes are still big ! How can I fix that ? Thanks.
PS : I cant change the viewport width meta to a specific pixel size because it mess the css "width:100%".
You gotta set the textsize using the html/css code.
I have a quite big problem with the layout of my WebView. I'm downloading content from an RSS collector site, including the article content.
This content may contain pictures or YouTube videos or whatever else. Downloading is not the problem, but rather displaying it.
The pictures will probably be too wide to fit the screen. This is not a problem - I can resolve that by setting the LayoutAlgorithm to SINGLE_COLUMN.
_webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
However, using SINGLE_COLUMN creates a problem for YouTube videos. They are resized in width, but not in height - resulting in the WebView displaying only a black picture instead of the video. There is no way of playing the video like this.
I can resolve this as well by setting the LayoutAlgorithm to NORMAL or NARROW_COLUMNS - however, that results in the pictures not being resized to the screen size as I'd like, and I have to scroll right/left in order to see the whole picture (which does not work very well because I have the WebView in a horizontal PageAdapter).
I can assume this may be the reason SINGLE_COLUMN is deprecated (developer.android.com). However, NARROW_COLUMNS just does not do what I'm expecting it to.
Does anyone have any idea how to resolve this issue?
Look at my answer here, the problem is that LayoutAlgorithm.SINGLE_COLUMN - is deprecated now.
The problem is that images in your html have fixed width - you have to fix it - setting max-width
Before posting this question I have searched a lot on this, however couldn't find any work around problem.
I have a screen with webview, I have configured webview with following settings:
1.WebPage can't scroll vertically or horizontally ,
2.Removed Zoom-In & Zoom-Out on webview
The HTML file which is displayed in webview has long text & using CSS3 content is devided into multiple columns that only accommodate screen size, displaying only that split content or say partial content from HTML page (not whole HTML page). Now I have to get that split content from webView from Java (Android) & objective-C (iOS) side without screen touch or long press, from CSS3 & JS I am not able to get it.
Is it possible to get visual text / content from webview ?
If anybody have faced such problem or knows any solution please reply it.
I am facing this problem for both Android & iOS app.
Thanks In Advance !
You could loop through the DOM with jquery, and merge the results, appending them to a hidden field.
http://api.jquery.com/each/
Then you could get that field from objective c, like this:
NSString *myFields = [self.webView stringByEvaluatingJavaScriptFromString: #"document.form1.myFields.value"];
For Android, you could try this:
Android - simple user input form web-view to back-end java with jQuery Mobile
I am using a WebView in an Android Activity to show a simple html who has a single jpg inside. When the jpg height is smaller than 3000 pixels, there is no problem, it show perfectly, but when the jpg is above 3000 pixels, it does not show. Can be this a limitation? Or memory issue? I am using Android 2.3 to test.
Your problem is that you're using a huge image, so the device can't handle that much data.
In order to display it properly and nicely mi advice is to use an html table wich each cell containing a slice of the image.
The browser will just render the parts of the table being displayed, so your image will be loaded properly.
I used this approach on a project and worked perfectly.
Regards.