The Canvas Demo app
Create a new project to explore the topic of drawing with Canvas
. We will reuse what we just learned, and this time we will also draw to the Bitmap
.
Creating a new project
Create a new project and call it Canvas Demo
. This time, be sure to choose the Empty Activity option on the Add an Activity to Mobile screen before clicking Next. Also, be sure to uncheck Generate Layout File and Backwards Compatibility (AppCompat). Don't worry about naming the Activity; this is just an app to play around with. We will not be returning to it.
Notice that Android Studio has not created an XML layout, and furthermore it has not added a line of code in MainActivity.java
that calls setContentView
. If you ran the app at this stage, you would get a blank black screen.
In addition, we are using the Vanilla version of Activity
class, and MainActivity
therefore extends Activity
instead of AppCompatActivity
, as we have been using previously.
Note
The complete code for this app can be found in...