Figure 4-11: The default icon (left) and a unique icon (right).
Creating a Launcher Icon for the Application
When your app is installed, its icon helps users identify its presence in the application launcher. When you create the Silent Mode Toggle application, the ADT automatically includes a default launcher icon, as shown on the left in Figure 4-11.
You should change this somewhat bland icon to one of your own. A round phone icon works for the Silent Mode Toggle application, as shown on the right in Figure 4-11. You can create your own (as shown in the following section) or use the one from the downloaded source code from this book’s website.
Figure 4-11: The default icon (left) and a unique icon (right).
Designing a custom launcher icon
Creating your own launcher icons is fairly easy, thanks to the Android project. The article “Icon Design Guidelines” in the Android documentation covers all aspects of icon design — a how-to manual for creating icons for the Android platform, a style guide, a list of do’s and don’ts, materials and colors, size and positioning guidelines, and (best of all) icon templates that you can use. You can find useful resources for designing icons at http://d.android.com/guide/practices/ui_guidelines/icon_design.html
and http://d.android.com/design/style/iconography.html
.
Working with templates
After you download the Android SDK, these icon templates and materials are available for you to use immediately on your computer’s hard drive. Navigate to your Android SDK installation directory (see Chapter 2), and from there navigate to the docs/shareables
directory. You’ll find various .zip
files that contain templates and samples. Open the templates in the image-editing program of your choice, and follow the design guidelines in the documentation to create your next rockin’ icon set.
Matching icon sizes with screen densities
Because every screen density requires an icon in a different size, you, as the designer, need to know how large the icon should be. Each density must have its own icon size to look appropriate (no pixilation, stretching, or compressing) on the screen.
Table 4-4 summarizes the finished icon sizes for each of the three generalized screen densities.
Table 4-4 Finished Icon Sizes
Screen Density |
Icon Size in Pixels |
Low-density screen (ldpi) |
36 x 36 |
Medium-density screen (mdpi) |
48 x 48 |
High-density screen (hdpi) |
72 x 72 |
Extra-high-density screen (xhdpi) |
96 x 96 |
Adding a custom launcher icon
To place your custom launcher icon into the project, follow these steps:
1. Rename the image icon to ic_launcher.png
.
2. Drag your icon into the drawable-mdpi
folder.
Eclipse asks whether you want to overwrite the existing ic_launcher.png
.
3. Click Yes.
The ic_launcher.png
file is now in the drawable-mdpi
folder.
You’re not done yet! For the ldpi,
hdpi
and xhdpi
folders, you need a low-, high-, and extra high density version of the icon. Copy the respective icons into the ldpi
, hdpi
, and xhdpi
folders.
If you don’t copy the icons of other densities into their respective folders, users who have a low- or high-density device receive the default launcher icon (refer to Figure 4-11), whereas the medium-density devices receive the new icon that you included in the project.
You dragged the file into the drawable-mdpi
folder — what gives? Each of the other folders contains its own version of the icon. Open the drawable-hdpi
, drawable-xhdpi
, and drawable-ldpi
folders in your Eclipse project, and you can see that each density has its own ic_launcher.png
file. Be sure to place the correct icon in each density-specific folder.