Designing in XML

There are two ways to define a user interface in Android: in code, or in XML. XML is usually recommended because it’s easier to create and style than the equivalent Java code.

Android Studio has a graphical layout editor to help you create beautiful user interfaces by dragging and dropping components such as buttons and lists onto a canvas, and then positioning them with your mouse. You should play around with the editor and use it whenever you like, but for this book we’re just going to work with the XML text that it creates. This will give you a better feel for how things work.

Creating the Main Screen

When users start the program, we want to show options for continuing a game, starting a new game, and for reading about what ...

Get Hello, Android, 4th 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.