Showing posts from December, 2021

Creating a Drawing View in Sketchware

 To create a DrawingView with undo button, follow the instructions given below. 1. Create a new project in Sketchware. 2. In main.xml , add a LinearLayout linear1 with height wrap_content, weight 1, and padding 0. Add a LinearHorizontal below it, containing following ImageViews: imageview_stroke_width , imageview_stroke_color , imageview_background , imageview_undo,  and  imageview_clear. 3. Create a more block canvas and put following codes in it. Here we create a new View class called DrawingView and a new class called PathPaint. } DrawingView dv; private Paint mPaint; private Canvas mCanvas; private ArrayList<PathPaint> all_paths = new ArrayList<>(); public class DrawingView extends View { private Bitmap mBitmap; private Paint mBitmapPaint; Context context; private Paint circlePaint; private Path circlePath; private Path mPath; public DrawingView(Context c) { super(c); context=c; mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); circlePath = new Path();