The example provided below shows how to Convert LinearView Into Image view  In SketchWare.
So Let's Follow Me.

convert linearview into imageview
Converted View

1. First of all Add "Linear" In View Area and add a "Button" according to image below.
Linear into image

2. Go To "More Block" Option And add More block according to image below.
save linearview

3. After adding more block Then set in more block Add Source directly component and copy codes below and paste copy codes into "Add Source directly" component according to image.

Copy Codes
_______________________________
Bitmap returnedBitmap = Bitmap.createBitmap(_view.getWidth(), _view.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
android.graphics.drawable.Drawable bgDrawable =_view.getBackground();
if (bgDrawable!=null) {
bgDrawable.draw(canvas);
} else {
canvas.drawColor(Color.WHITE);
}
_view.draw(canvas);
java.io.File pictureFile = new java.io.File(Environment.getExternalStorageDirectory() + "/Download/myimage.png");
if (pictureFile == null) {
showMessage("Error creating media file, check storage permissions: ");
return; }
try {
java.io.FileOutputStream fos = new java.io.FileOutputStream(pictureFile); returnedBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
showMessage("Image Saved in /Download/ folder");
} catch (java.io.FileNotFoundException e) {
showMessage("File not found: " + e.getMessage()); } catch (java.io.IOException e) {
showMessage("Error accessing file: " + e.getMessage());
}
_______________________________
save Linear from storage in sketchware


4. after that go to View option and then button and set blocks according to image below.
File in Sketchware

How To Save View In Sketchware



  

            

Post a Comment

Previous Post Next Post