Html content is overlapping when large content is loading in the web view. Is there a solution
for this problem?
reportView.setBackgroundColor(0);
reportView.getSettings().setBuiltInZoomControls(true);
reportView.setInitialScale(100);
reportView.getSettings().setUseWideViewPort(true);
reportView.clearView();
Try to use:
webSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
in webview settings.
Fixed Html content is overlapping issue, when large content is loading in the web view.
webSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
In addition to the above line, trying to reset webview instances every time
.
Related
I am working on a newsreader app in which we have a Webview to display news details. Can I add an Admob layout between the contents inside this webview?
Basically, it should look like this,
-Webview
-Paragaraph1
-Admob layout
-Paragraph2
-Webview
There should be only one webview and the Admob layout should be inside the webview, placed between content.
I tried with splitting the html content and loading them in multiple webviews inside a Recyclerview. But its affecting the performance a lot.
Any help regarding this would be appreciated.
I think it isn't possible and also it isn't a good practice as you are adding your ads on someone else's data.
And if it is your data you can always change the HTML page
Is any way to add the Html contents in to the webview through the Main Xml file.
I have a one problem.I'm new in the android field,I load the contents from the assets file and normally the webview contents visible but when i going to swipe the page ,that contents not visible only containing black page ,after swipe next page visible...
so ,anyone give me the tips how to solve this problem.
advance in Thanks...
Check this.....
https://developers.google.com/chrome/mobile/docs/webview/gettingstarted
how to show the html contents to the webview using android
I think this link can help you: Displaying Android asset files in a WebView?
However, you should give us more information. If you want to view an external URL, you will need to add permisions on the Android Manifest. If that is not your case and your content is local, maybe the problem is inside your Webpage.
I want to load two html pages into two different webviews in android.The first html only going to display. The second html should act as background. The script used in second html page need to run, but it won't display to the user. Let me know this is possible in android..
Thanks
Yes dude it is possible
Add a WebView and set it visibility to View.GONE
Like
WebView webView2=new WebView(this);
webView2.setVisibility(View.GONE);
then
webView2.loadUrl("javascript:MyJSFunction(..)
I encounter a problem of display with a webview i'm using in one of my application.
When I call loadData, the webview first display the text and then load the images of the page (standard behaviour).
Sometimes, if those images modify the text position, the old text position is not cleared and both old text and new text+image is displayed
Here a screenshot of what it looks like when the problem occurs:
It's like the webview do not redraw correctly it's content. Of course a simple invalidate() does not work...
It do no occur often but lets say one time over 20.
Code used to display the data (called outside Activity life cycle methods):
// Include the html headers to the content received from WS
String webtext = String.format(ConfigApp.HTML_BODY, wsdata.getText());
mWebView.setWebChromeClient(...);
mWebView.setWebViewClient(...);
mWebView.setBackgroundColor(0);
mWebView.loadDataWithBaseURL(null, webtext, "text/html", "UTF-8", null);
Any idea how to fix this?
I've finally found a way to fix the problem.
Remove the WebView transparent background:
String webtext = String.format(ConfigApp.HTML_BODY, wsdata.getText());
mWebView.setWebChromeClient(...);
mWebView.setWebViewClient(...);
// mWebView.setBackgroundColor(0);
mWebView.loadDataWithBaseURL(null, webtext, "text/html", "UTF-8", null);
Because my WebView has a blank background it's ok for me. Maybe it can be annoying for somebody else.
For sure it's a WebView bug.
I have frequently had sporadic problems with WebViews not displaying properly after having loaded content with loadDataWithBaseUrl. Although the WebView's height was set to wrap_content, the WebView wouldn't always resize to wrap the content. Instead the webview had a height of zero. Sometimes it would display fine and other times it would not. Sometimes the problem would only happen in a portrait orientation and landscape would work fine. I tried removing my setBackgroundColor call but that it did not help. However, I was able to get the problem to go away today by changing the layout that the WebView was in from a LinearLayout to a RelativeLayout.
If you set your WebView to a specific size, and not "wrap_content" , then after the data is loaded, the webview doesn't resize its content correctly.
I think it's a bug with the widget..
So..
Try to use "wrap_content" in the layout_height attribute.
Try
mWebView.setBackgroundColor(0x00ff0000);
You just have to call refreshDrawableState() method after calling loadDataWithBaseURL() method
and its will resolve your problem
mWebView.loadDataWithBaseURL(null, webtext, "text/html", "UTF-8", null);
mWebView.refreshDrawableState();
I am working on a webview with local html file as source.
I am trying to copy a Webview on to another webview.
If I do this.
WebView1.loadUrl(webView2.getUrl());
I works, but it is same as loading the webview again,which i dont want. If I do this
WebView1=WebView2;
It doesn't copy. The content of WebView1 doesn't change. Am I doing anything wrong.
You'll have to remove the current WebView from your Layout (by calling removeView(WebView1) on it's container) and then add the new WebView to it (addView(WebView2) on the same container). Obviously you'll have to take care that it gets inserted at the right place again. Easiest way would be to just wrap a FrameLayout around it and call said methods on it.
Can't promise you that this will work though, since I don't know how WebView behaves offscreen.