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()");
Related
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 working on web app which i am using web view to load that directly from website url. At the time of loading that url in android webview it is loading very slowly that it is taking nearly 5 -7 seconds for loading,in the mean while white screen is displaying. So, what i am thinking is while the process of loading webview, i want to display an image on screen and after 5 seconds the app will load. so that by displaying 5 seconds any image in the mean while webview loads so, the user can directly access the app without facing any time delay(like getting white screen).
My code is :
WebView webview = (WebView) findViewById(R.id.webView1);
websetting = webview.getSettings();
websetting.setJavaScriptEnabled(true);
webview.setVerticalScrollBarEnabled(false);
webview.loadUrl("/**here loading my url which is taking nearly 5-8 seconds to load**/");
I tried using splash screen, but here after splash screen has been timed out then webview is loading.
So, can anyone help me with this. Loading of image while webview is loading.
You can cache the image on the disk for each call. Before displaying the image check if the image already exists on the cache. If it does load it from there, else download the image to the cache and load it from there. While the image is loading, show a stub to the user. I've done this with an image view before.
Beware that your cache image may be stale. Your code must handle that too. Here is a related question where this has been implemented
Lazy load of images in ListView
Some of the top answers on that question do not use good coding practices on android so watch out for that.
I am trying to make an image map similar to AndroidImageMap. Now, i need to know whether the same implementation with android webview is possible? Because, the image map can be processed in the server side and implemented as HTML image map. If we use to display the HTML image map's URL in a webview, then how can the click events be recognized from the webview co-ordinates clicked?
Note : I need to perform respected action when the corresponding image map co-ordinates clicked.
I have an Android WebView loaded with a html file(actually stored in some folder under sdcard) that is having one/two/three image(s). Is it possible to drag-drop any one of those images?
If its possible, below are my doubts
When i drag an image from (x1,y1) place and drop it in another (x2,y2)place, How can i change the original source file code as the image place is changed ?
When i open the same html file in next time (using default html viewer or my app), i should see the image in (x2, y2) place. Isn't it possible ?
I tried this drag ImageView inside a WebView. But it is just adding an imageview to webview. (So, when i run the same app next time, i don't see the image in the place where i dropped it in first run.) But i need to drag an image presented in source html file. So After every drag-drop, Do i need to render the webview content and create a new html file to see the image in dropped location?
Is it possible to read the android-webview content? (like we read the web page content in java).
Can anyone clear my doubts and suggest me a better way if iam going/thinking wrong?
I don't think it possible (without using some not trivial tricks) to implement the drag and drop as you wish. for the other point's you raised - if the file is on your sd - why not just parse the html file and get the pictures positions and source link and use it to implement the drag and drop on your own? after all- the html file is an xml file which contains attributes which defines positions/links/images/text
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");