Adding custom buttons to the screen
We need to let the user control when to start another drawing and clear the screen of their previous work. We need the user to be able to decide if and when to bring the drawing to life. To achieve this, we will add two buttons to the screen, one for each of the tasks.
Add the members highlighted next in the LiveDrawingView
class:
// These will be used to make simple buttons private RectF mResetButton; private RectF mTogglePauseButton;
We now have two RectF
instances. These objects hold four floating-point coordinates each, one coordinate for each corner of our two proposed buttons.
Initialize the positions in the constructor of LiveDrawingView
:
// Initialize the two buttons mResetButton = new RectF(0, 0, 100, 100); mTogglePauseButton = new RectF(0, 150, 100, 250);
Add the import
for the RectF
class:
import android.graphics.RectF;
Now we have added actual coordinates for the buttons. If you visualize the coordinates on the...