Posts

Showing posts with the label load image from assets to WebView

Loading images in WebView in Sketchware

Image
We can use WebView for loading images from any url or for loading images from drawable folder, assets folder, or resource folder of our app. 1. To load an image from a website in WebView, we can directly write the url of the image in the WebView loadUrl block. Even animated gifs can be loaded directly to WebView. WebView   webview1   loadUrl   http://.....jpg 2. We can modify the width and height of this image loaded in WebView by using following code in  WebView loadUrl  block: WebView   webview1   loadUrl   data:text/html,<img width=100% height="" src="(imageUrl)"> We can make it fit the width of the screen by setting width=100% in above code. 3. We can also load the images added using Image Manager in Sketchware (images in drawable folder) with following code: WebView   webview1   loadUrl   file:///android_res/drawable/image Note that in above code image is name of the image and has to be changed accordingly. Note that animations d