Understanding the Canvas class
The Canvas
class is part of the android.graphics
package. In the next two chapters, we will be using all the following import
statements from the android.graphics
package and one more from the now familiar View
package. They give us access to some powerful drawing functions from the Android API:
import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.widget.ImageView
First, let's talk about Bitmap
, Canvas
, and ImageView
, as highlighted in the previous code.
Getting started drawing with Bitmap, Canvas, and ImageView
As Android is designed to run all types of mobile apps, we can't immediately start typing our drawing code and expect it to work. We need to do a bit of preparation (that is, more coding) to consider the specific device that our app is running on. It is true that some of this preparation can be slightly counterintuitive, but we will go through this one step...