Posts

Showing posts with the label image zoom

How to make an image zoomable and fit screen width in WebView

Image
We can make an image fit screen by setting scale_type as FIT_XY under image properties. But it is difficult to zoom an image in imageview in Sketchware. In order to make an image zoomable, we have to insert code to make the WebView zoomable, and then load the image in webview. To insert a zoomable image which fits screen​, follow the steps below. Step 1 . In your Sketchware project, insert a webview in View area. Step 2 . Go to Image Manager  and add an image ' myimage.jpg '. Step 3 . Use block Webview loadUrl and write file:///android_res/drawable/my image.jpg Step 4 . Use block add source directly  and write the following code: webview1.getSettings().setBuiltInZoomControls(true);webview1.getSettings().setDisplayZoomControls(false); webview1.getSettings().setLoadWithOverviewMode(true); webview1.getSettings().setUseWideViewPort(true); The code above enables pinch zoom in WebView. It is applicable to anything loaded in WebView and not just the image. It...