Understanding Layouts

Now that you have created the Screen Brightness Toggle application inside Eclipse, you can begin to design the application's user interface. Because the user interface is the part of your application with which your users interact, you must make this area of the application as quick and responsive as possible in all regards.

For the Screen Brightness Toggle application, all you need is a single button centered in the middle of the screen to toggle the screen brightness. Directly below the button you can include some text that lets the user know whether the tablet is in regular daytime mode or in night mode. (See Figures 6-2 and 6-3, respectively.)

Figure 6-2: The Screen Brightness Toggle application in daytime mode (100% screen brightness).

image

Figure 6-3: The Screen Brightness Toggle application in night mode (20% screen brightness).

image

Understanding the XML layout file

All layout files for your application are stored in the res/layouts directory of your Android project in Eclipse. Android Development Tools (ADT) creates a default layout file when you create a new application. When you created the Screen Brightness Toggle application, the ADT created a file in the res/layouts directory named main.xml.

Open that file by double-clicking it, and the XML code appears ...

Get Android™ Tablet Application Development For Dummies® 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.