I try to load a HTML page into an Android Webview using loadData function. The issue is that the first time I scroll down the view, it seems like is loading the HTML code.
Is possible to load the HTML site completely before showing the webview?
Otherwise, this first time the view goes slowly down and blink a lot.
I'm getting this webview through a FragmentManager
Thanks in advance.
Try to disable the hardware accelerator on the activity:
android:hardwareAccelerated="false"
This may help :myWebView.setBackgroundColor(Color.TRANSPARENT);
Related
I have done my research and I haven't found a suitable question for my problem. I got a WebView inside a ScrollView, and once I get the HTML from my service, I call
myWv.loadDataWithBaseURL(null,myHtml,"text/html","utf-8",null);
Nothing special there. The problem I'm having is that, when I run my Application in a 4.4.2 Android tablet, the WebView loads the HTML with the words split in lines, eg:
This
is
my
sentense
And after a second it renders the HTML correctly but the ScrollView's scroll is as big as the number of lines it rendered before loading the HTML correctly. I have tested in 3 different smartphones and everything is fine, only in the tablet it seems to happen, probably due to some performance issue since my HTML is huge.
Does any of you have have had this problem before and knows how to solve it? Thanks in advance.
Extend WebViewClient. And in your custom WebViewClient overload the method onPageFinished.
#Override
public void onPageFinished(WebView view, String url) {
// If you create a listener, here you can trigger it
// you can show the webview here as it will be already measured.
}
If you show the webview when the page is already entirely loaded there won't be any ugly animation.
I have a simple Activity to show a webview and a back button. Here is the code that I use to load the URL that I want in the webview.
The webpage that I am loading in on a server online, it has a few form elements plus a few links that when clicked I need to keep loading them inside the webview.
Now the problem is very often the page loads without the images, I can see the form elements though or only blank white page. I am testing this on wifi so internet is working fine.
Why is it not loading images and how can I make sure it does? I even tried making all images in the html page have absolute paths, but that did not help.
Later Edit: I found out what was causing this. Maybe others will run into this. I had this in the manifest file android:hardwareAccelerated="true". After removing it the content inside all the webviews is loading smoothly.
Second later edit: It is terrible, I get the initial page load now, but forms are not submitting and after some going back and forward to the webview, new images do not load anymore. Is it a memory problem? How do I make it start fresh every time?
WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient());
wv.loadUrl(filepath);
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 have an app which i want to open a webview
right now i am loading the webview the most simple way
i would like to load the webpage in the background so the user will not have a waiting time
maybe in a service running in the background or in a prevoius activity
i looked around the forums and could not find a refrence to the subject
help will be appriciated.
Thx
You can set the webview's visibility to GONE and load the page and when onPageFinished is fired, you can then show the webview.
Hope this helps.
I hade the same problem a while ago, I know what you want. Asynctask! here is a good link I read on to get it to work!
http://www.brighthub.com/mobile/google-android/articles/82805.aspx
How you get it to work properly.
Load your webview in the doInBackground and perhaps a ProgressDialog that shows that your app i working?
GL mate
you can use asynctaskLoader take a look it's better than the asynctask because it can manage the orientation changed and some other cool things...
I'm developing an application which is mainly a webview and will display a JQTouch UI. Two of the 3 views work just fine, however, I have a view which loads another page with a form which does not work at all. This view loads up just fine but when I click the link to go to the form the link just stays highlighted and nothing happens. I have overriden all of the methods in webviewclient and webchromeclient and placed breakpoints within with no luck. None of the hooks catch when I click the links.
The part that truly confounds me is that it works in the phones browser but not in my webview. Is there a setting on webview that I may be missing which would make it act like the phones browser?
Any help or suggestions would be appreciated.
The fix for this was to override onLoadResource as the link was being treated as a resource and not a new page load. I tried calling webView.loadUrl right in the override of loadREsource but that caused an endless loop so I had to write some logic to load the url properly into my webView. This seems a bit hacked but it works.