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);
Step 5. Save and run your app.
The video below shows an example of how to implement it.
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);
Step 5. Save and run your app.
The video below shows an example of how to implement it.
https://drive.google.com/file/d/13S_R35J9POoMXahJtpbpnLH2O6HzyiRP/view?usp=drivesdk
BalasHapus