Laying Out the Application

When you have the Silent Mode Toggle application created inside Eclipse, it’s time for you to design the application’s user interface, the part of an application where users interact with the app. This area of your application should be as snappy as possible.

Your application will have a single button centered in the middle of the screen to toggle silent mode. Directly above the button, an image will provide visual feedback to let the user know whether the phone is in silent mode or normal ringer mode. Figures 4-2 and 4-3 show what the finished application will look like.

Figure 4-2: The Silent Mode Toggle application in normal ringer mode.

9781118417454-fg0402.tif

Figure 4-3: The Silent Mode Toggle application in silent ringer mode.

9781118417454-fg0403.tif

Using the XML layout file

All layout files for an application are stored in the res/layouts directory of the Android project in Eclipse. When you create the Silent Mode Toggle application, the Android Development Tools (ADT) creates a file named activity_ main.xml in the res/layouts directory. This default layout file is the one the ADT creates for you when you create a new application.

Double-click the file, click the activity_main.xml tab at the bottom of the screen, and you see some XML in the Eclipse editor window, as shown in Figure ...

Get Android Application Development For Dummies, 2nd 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.