Basics Project 107g Building the drawing app with MIT App Inventor 2

Basics: Project 107g

Project name: Building the drawing app with MIT App Inventor 2

Tags: MIT App Inventor 2, Drawing app

Attachments: DigitalDoodle.aia and DigitalDoodle.apk


We will learn how to build a drawing app with the MIT App Inventor 2 software. This project will show you how to draw a line on the screen as the user drags a finger around.

We assume that you have read our previous projects about MIT App Inventor 2.

Step By Step instruction

1.Go to and click on Create Apps! orange button.

create apps

2.Click on Start new project and give your project a name. As we’re just exploring the MIT App Inventor 2, you can name it as DigitalDoodle. Click on OK button. Your project will be saved.

start new project

Ball game

3.Go to Designer editor tab.

4.Select components to design your app. From the Drawing and Animation drawer, drag out a Canvas component and drop it onto the Viewer.


5. Set the Screen so that it does not scroll. The default setting for MIT App Inventor 2 is that the screen of your app will be “scrollable”, which means that the user interface can go beyond the limit of the screen and the user can scroll down by swiping their finger (like scrolling on a web page). When you are using a Canvas, you have to turn off the “Scrollable” setting (UNCHECK THE BOX) so that the screen does not scroll. This will allow you to make the Canvas to fill up the whole screen.


6. Change the Height and Width of the Canvas to Fill Parent. Make sure the Canvas1 component is selected so that its properties show up in the Properties Pane. Down at the bottom, set the Height field to “Fill Parent”. Do the same with the Width field.


7. Go to Blocks editor tab. So far you have been arranging your app’s screen and components in the Designer, which is in a web browser window. To start programming the behavior of the app, you need to go to the Blocks editor. Click the Blocks button in the upper right of your screen to go to the Blocks Editor.


8.On the left side of the Blocks Editor, click the Canvas1 Drawer to view the Canvas’s blocks. Drag and drop the block when Canvas1.Dragged do in the work area (the open area on the right).


Those mustard yellow blocks are called event handler blocks. The event handler blocks specify how the mobile device should respond to certain events: a button has been pressed, the phone is being shaken, the user is dragging her finger over a canvas, etc. when Canvas1.Dragged do is an event handler.

10. Get a Canvas1.DrawLine call block. In the Canvas1 drawer, pull out the when Canvas1.DrawLine method block.


11. Use the get and set blocks from the when Canvas1.Dragged do block to fill in the values for the call Canvas1.DrawLine block. The when Canvas1.Dragged do event will happen over and over again very rapidly while the user drags a finger on the screen. Each time that when Canvas1.Dragged do event block is called, it will draw a small line between the previous location (prevX, prevY) of the finger to the new location (currentX, currentY). Mouse over the parameters of the when Canvas1.Dragged do block to pull out the get blocks that you need. (Mouse over them, don’t click on them.)

12. Try it out on your device or with the emulator! It is a good habit while building apps is to test while you build. MIT App Inventor 2 lets you do this easily because you can have a live connection between your phone (or emulator) and the MIT App Inventor 2 development environment. Try to drag your finger around the screen. Do you see a line?

13. Congratulations, your drawing app is running!

14.While your device (emulator or phone/tablet) has been connected to App Inventor, your app has been running in real time on your device. If you disconnect the emulator/device from the Blocks Editor, the app will vanish. You can always make it return by reconnecting the device. To have an app running without being connected to App Inventor, you must “package” the app to produce an application package (apk file). To “package” the app to install on your device or to send to someone else, click the Build tab at the top of the screen. Under Build, there are two options available for you to choose from:

  1. App (provide QR code): You can generate a Barcode (a QR Code), which you can use to install the app on a mobile device that has a camera, with the aid of a barcode scanner, like the ZXing barcode scanner (freely available in Google Play). This barcode is only good for two hours. If you want to share your app with others via barcode over a longer period, you’ll need to download the .apk file to your computer and use a third-party software to convert the file into a barcode. More information can be found here.
  2. App (save to my computer): You can download the app to your computer as an apk file, which you can distribute and share as you like by manually installing it on other devices. (sometimes called “side loading“).


We have successfully built the drawing app with MIT App Inventor 2. There are many ideas on how to extend this project, for example:

  • Change the color of the ink (and let the user pick from a selection of colors).
  • Change the background to a photograph or picture.
  • Let the user draw dots as well as lines (hint: Use DrawCircle block).
  • Add a button that turns on the camera and lets the user take a picture and then doodle on it.


Leave a Reply

Your email address will not be published.