Anonymous Inner Class That Implements Interface OnSeekBarChangeListener to Respond to the Events of the widthSeekBar
Lines 93–127 define the lineWidthChanged OnSeekBarChangeListener
that responds to events when the user adjusts the SeekBar
in the Choose Line Width dialog. Lines 96–97 create a Bitmap
on which to display a sample line representing the selected line thickness. Line 98 creates a Canvas
for drawing on the Bitmap
. Method onProgressChanged
(lines 100–116) draws the sample line based on the current drawing color and the SeekBar
’s value. First, lines 105–109 configure a Paint
object for drawing the sample line. Class Paint
’s setStrokeCap method (line 108) specifies the appearance of the line ends—in this case, they’re rounded (Paint.Cap.ROUND ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.