Objectives
In this chapter you’ll:
Detect when the user touches the screen, moves a finger across the screen and removes a finger from the screen.
Process multiple touches so the user can draw with multiple fingers at once.
Use a SensorManager
and the accelerometer to detect motion events.
Use an AtomicBoolean
object to allow multiple threads to access a boolean
value in a thread-safe manner.
Use a Paint
object to specify the color and width of a line.
Use Path
objects to store each line’s data and use a Canvas
to draw each line into a BitMap
.
Create a menu and display menu items on the action bar.
Use Android 4.4’s immersive mode to enable the user to draw on the entire screen.
Use Android 4.4’s printing framework and the Android Support Library class PrintHelper
to enable the user to print a drawing.
7.2.1 Using SensorManager
to Listen for Accelerometer Events
7.2.3 Drawing with Canvas
and Bitmap
7.2.4 Processing Multiple Touch Events and Storing Lines in Path
s
7.2.5 Android 4.4 Immersive Mode
7.2.6 GestureDetector
and SimpleOnGestureListener
7.2.7 Saving the Drawing to the Device’s Gallery
7.2.8 Android 4.4 Printing and the Android Support Library’s PrintHelper
Class
7.3 Building the App’s GUI and Resource Files
7.3.4 Menu for the DoodleFragment
7.3.5 activity_main.xml
Layout for MainActivity
7.3.6 fragment_doodle.xml
Layout for DoodleFragment
7.3.7 fragment_color.xml
Layout for ColorDialogFragment
7.3.8 fragment_line_width.xml
Layout for LineWidthDialogFragment
7.3.9 Adding Class EraseImageDialogFragment
7.8 LineWidthDialogFragment
Class
7.9 EraseImageDialogFragment
Class
Self-Review Exercises | Answers to Self-Review Exercises | Exercises