I have issue.
I'm using webview for html loading. Webview contains contenteditable="true" for editing.
Html can be with img and blockquote tag.
In android till 12 webview all img show fine, but in android 13, then you click in webview for editing, webview change real images to obj as shown in screen:
It seems like webview applies some resizing or scaling.
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.
We have problem with embedded video playing in WebView's on Kindle Fire HD 7" with latest firmware (Android 4.0.3, firmware rev 7.4.6).
Prerequisites:
static magazine page image (from JPG file) displayed on screen (ImageView used);
HTML page displayed over static image (WebView inside custom layout; both WebView and
layout backgrounds are transparent!);
HTML page contains 'video' tag inside 'iframe' tag.
On all tested devices this combination works fine: WebView draws with transparent background over static page image, so, video on HTML page properly placed inside static JPEG from ImageView. Except Kindle Fire.
On Kindle Fire, WebView always draws with white non-transparent background. WebView doesn't react to setBackgroundColor or setBackgroundDrawable calls. Attempt to set HTML body background color from Javascript also unsuccessful. So, static image is not visible under HTML 'overlay'.
Suggested by this topic - Android WebView style background-color:transparent ignored on android 2.2 - I'm trying to switch off hardware acceleration for WebView:
webView.setBackgroundColor(0x00000000);
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
Kindle Fire draws WebView with proper, transparent background. But video on web page fails after that! More precisely, when starting video, only audio play, no picture.
Summary: hardware acceleration on - WebView draws with improper background; hw acceleration off - video in HTML plays without picture.
Few days googling doesn't result in any solution. Somebody solved a similar problem on the Kindle Fire or other device?
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 want to download and load images into Webview as they are downloaded (embedding direct image url's into the HTML is not an option)
When I call the webView.loadData(myData.. the full page is refreshed and the user's app is repositioned to 0,0 - is there a way where I can append to the HTML with the new image as and when it is downloaded? I am looking for a way to override the functionality of resetting the position of the webView on a call to loadData
Thanks
Can you handle the problem in JS side by trigering an event to document when the app has downloaded images ?
Like :
myWebView.loadUrl("javascript:imagesLoaded()");
I use WebView.loadDataWithBaseURL for loading my help page from internal resources of my application.
I have help.html and a few images located in the assets directory. The page loads and shows with images, but the text around image is a mess. It did not show on the right side of the image, instead the image overlaps the text.
This happens only on first loading of the page. If I close the WebView and open it again, then everything is fine.
It seems that at first loading WebView spends some time for loading images and does not reformat page after that. On the second attempt images are cached and displayed together with text and properly formatted.
What is the solution for this problem?
Did anyone face this problem too?
Here is my code:
app.setContentView(R.layout.help);
final WebView web = (WebView) app.findViewById(R.id.helpWebView);
web.setBackgroundColor(0);
web.loadDataWithBaseURL("file:///android_asset/", helpHtml, "text/html", "utf-8", null);
Web page is inside the helpHtml string with the code:
<html><head></head><body><img src="html/flddesc.png" align="left"/>this should be my long long text...</body></html>
P.S: html/flddesc.png is a PNG8 image 180x200 ~20kb of size
Try this function:
webview.loadUrl("file:///android_asset/your_html.html");