The Canvas Demo app
First, create a new project to explore the topic of drawing with Canvas
. We will reuse what we have learned and, this time, we will also draw to the Bitmap
instance.
Creating a new project
Create a new project and call it Canvas Demo
, and make sure that you choose the Empty Activity template option.
In this app, we will make a change that we have not seen before. We will be using the vanilla version of the Activity
class. Therefore, MainActivity
will inherit from Activity
instead of AppCompatActivity
, as has been the case previously. We are doing this because we are not using a layout from an XML file, and so we have no need for the backward compatibility features of AppCompatActivity
as we did in all the previous projects.
You should edit the class declaration as follows.
class MainActivity : Activity() {
You will also need to add the following import statement:
import android.app.Activity
Note
The complete code for this app can be found in the download bundle in the Chapter20...