Now that we’ve got some planning underway, let’s get to work. The first piece is the homescreen of the app. Let’s take a look at that mock-up we drew earlier:
Before we do any work on making that app happen, let’s have a quick crash course in Android layout development. Android layouts can be designed in either of two ways: it can be declared though XML, or it can be created programmatically through Java statements. We will look at both of those later on, though more focus will be given to XML layouts. This is because XML layouts are how you’re going to be designing most, if not all, of your layouts. Java programmatic layout design is used as a secondary means of doing custom / dynamic layouts.
XML layouts are done hierarchically and are composed of views. A view is a prepackaged module that you can use easily in your applications. (For a quick intro to Android layouts, check out this link: Google Developer’s Hello, Views Blog Entry.)
Let’s look back at our planned layout and break it down into its component views:
Remember how I said that the views are hierarchical? Well, here’s the hierarchy of the homescreen:
This is a simple layout; more complicated layouts have more levels of hierarchy.
Now that we understand the hierarchy, how do we put this into a project? Let’s move to the next tutorial: setting up a project and putting some code in it.