Chapter 22 Styles and Themes
Color Resources
Begin by defining a few colors that you will use throughout the chapter. Edit your colors.xml file in
res/values to match Listing 22.1.
Listing 22.1 Defining a few colors (res/values/colors.xml)
Color resources are a convenient way to specify color values in one place that you reference throughout
your application.
Styles
Now, update the buttons in BeatBox with a style. A style is a set of attributes that you can apply to a
widget.
Navigate to res/values/styles.xml and add a style named BeatBoxButton. (When you created
BeatBox, your new project should have come with a built-in styles.xml file. If your project did not,
create the file.)
Listing 22.2 Adding a style (res/values/styles.xml)
Here, you create a style called BeatBoxButton. This style defines a single attribute,
android:background, and sets it to a dark blue color. You can apply this style to as many widgets as
you like and then update the attributes of all of those widgets in this one place.
Now that the style is defined, apply BeatBoxButton to your buttons in BeatBox.