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 in the LiveDrawingView
class, as follows:
// 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
as follows:
// Initialize the two buttons mResetButton = new RectF(0, 0, 100, 100); mTogglePauseButton = new RectF(0, 150, 100, 250);
Now, we have added actual coordinates for the buttons. If you visualize the coordinates on the screen, then you will see that they are in the left-hand top corner, with the...