Creating the user interface

As previously mentioned, the user interface is the means by which the user of an application interacts with the app. It cannot be overstated how important the user interface of an application is. Before embarking on the process of actually coding a user interface, it may be helpful to make a graphical representation of the UI to be implemented. This can be done with different tools, such as Photoshop, but for this case, a simple sketch is sufficient:

From the preceding sketch, we can see that we will need two distinct screens in this application: the landing screen and the game screen where the actual gameplay will happen. These two screens will require two separate activities. We'll call these two activities MainActivity and GameActivity.

MainActivity will serve as the entry point of our application. It will contain the user interface and all logic pertaining to our landing screen. As we can observe in our sketch, the UI of the landing screen contains the application title, a view that shows the user their current high score, and three buttons performing different actions. The NEW GAME button, as the name implies, will lead the user to the activity in which the gaming takes place. RESET SCORE will reset the score of the user to zero and EXIT will close the application.

GameActivity will be the programmatic template of the game screen. In this activity, we will create the views and logical interactions between the user and the game. The UI of this activity contains an action bar with the title of the application displayed on it, two text views that display the current score of the user and their high score, and a layout element in which the Tetris gameplay will happen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.245.1