Understanding the Canvas class
The Canvas
class is part of the android.graphics
package. If you look at the import
statements at the top of the Sub' Hunter code, you will see the following lines of code:
import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.view.Display; 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 on 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 (coding) to get things working. It is true that some of this preparation can be slightly counterintuitive, but we will go through it a step at a time.
Canvas and Bitmap
Depending on how you use the Canvas
class, the term...