I want to load a part of Website to Webview. Not completed Website.
How can I do it?
It is similar this question.
Load a div into a webview on Android
But the answer only load text. not have Image.
Any one there?
1.Create a HTML file with a frame (or iframe) in it and save it in your assets folder.
2.Load your file in webview from assets .
Related
I'm making a webapp and the webview of android studio isn't loading a particular gif but it loads all other images and gifs, but while the website loads the gif as usual. i had made the javascript in the website to show it until another image is loaded.
i tried settings.domStorageEnabled = true
and it doesn't seem to help ! please help me figure out what's the problem.
You can try the below cod snippet to load the .gif into webview:
Create a html file like this:
And store it in "assets" folder of you application also store your gif in the same folder. And do following to show it:
webview.loadUrl("file:///android_asset/your_html.html");
Other option is use the below lib.:
https://github.com/koral--/android-gif-drawable
If the answer is help you, please upvote.
I have a live website which I want to show in my app with WebView. But also I want to add a css file in my website which will only work if This particular app load the website. Otherwise that css will not work.
Is this possible? If possible please anyone can tell me how to do that?
Put your index.html of your Website and the css file in the assets folder of your Android project. Modify your index.html so it will load the css file by adding a link to it.
Then when loading the WebView, just load the index.html from your assets folder and you are done. Like so: webView.loadUrl("file:///android_asset/index.html")
im a new android developer.
My app has WebView which loads lot of data from my site (which has pics, css, JS files).only the html code is updated weekly. other files are almost never changed. so i was thinking of including these static files in android assets, loading only the html from server and other files from assets and cutting down the loading time. how do i do it.
Android WebView Javascript from assets
and as shown in the above solution i cant change the html code to load these from assets because this site will also be accessed by web users.
Is there a way to do this. Thanks in advance..
Firstly you need to have relative paths
<img src="images/someimage.png">
not
<img src="www.mysite.com/images/someimage.png">
Then you need to load the HTML code not using webBrowser, for example like here
And then you can load HTML source into WebBrowser using base URL pointing to your assets like here
i am trying to load local images in android webview by using assets folder, but when i tries to open it, it is loading only HTML but not images
In my HTML Code i have added following line
<IMG SRC="file:///android_asset/images/a.jpg">
But it is not displaying image, can anybody please help?
put your images into the Assets folders by creating separate images folder like assets/images and then in your html page provide path of your image as
<IMG src="images/test.png">
first of which url loading in webview, is it local url or http (means requires internet). If ur loading local file system url pealse check the image path properly, it should work. if loading http url trying load a local images inside it sorry its not possible. Here its cross domain issue will restrict to that.
i have try to load swf in android.i use this :
but,i think that this is recommend to store SDCARD first and trying to display?
my question is, my point of view is correct or wrong?
i have try by android_asset but not get success.
First of all, I think you should use webview control to load SWF file. (if you have not done above).
Using webview, You can load swf file in any of following way,
Android Asset.
From SD Card.
URL from web.