Join David Gassner for an in-depth discussion in this video Create a custom launcher icon, part of Android App Development Essential Training (2015).
- When you design an Android app, you want to add images to make it colorful and interesting to look at. And the first image that you always see with your app is the launcher icon. That's the graphic that appears on the launcher screen, and also on the app list to visually identify your application. Notice the wide variety of colors that are used in the standard Google applications. But also notice some common themes. First of all, you won't see any icons that are just simple squares.
There's always a certain amount of transparency. Also, the colors tend to be flat. You don't see a lot of texture in these icons, and that's to fit in with the material design visual language. I'll show you how to add a launcher icon into an existing application. I'm working in a project now called LauncherIcon, and in this version of the project, I've changed my application layout so that it's only displaying some long text.
When I run the app on the device, I only see the long text that I'm adding, and then I can still scroll up and down because it's still wrapped inside a ScrollView container. Each brand new Android project that you create in Android Studio has a default launcher icon. It's a simple graphic of Andy the Android. But this is what you want to replace to brand your app. Now I've already included a graphic that we can use in the Exercise Files. It's in the Assets Folder under logo, and it's a PNG file with transparency behind the circular shape.
This image is perfect for use as a launcher icon because it has transparency and it's not a perfect square. To add it to my application, I'll go back to Android Studio. I'll select the app module in the project window, and then choose New Image Asset. For my Asset Type, I'll select Launcher Icons. Then for the Foreground, I'll choose an Image. I'll browse, and then I'll press Control D or Command D to jump to my Desktop.
From there I'll go to my Exercise Files to Assets to Logo, and I'll choose logo.png. And I see the graphic shown on the right. Notice that there are five different versions of it. One for each of the standard pixel density buckets. I'm going to be generating a bunch of different versions of this file, but it's all going to be done for me. Now if I like, I can customize the appearance of this graphic. You could add a circle around it, and add additional padding, and then change the background color.
Or, you could wrap that inside a square shape, making it vertical or horizontal. And you can even add something called a Dog-ear effect. But, I'm going to keep this very simple. I'll set my Shape to None, my Additional padding to nothing, and I'll accept the graphic in its current state. I'll accept the resource name of ic_launcher, and that's going to result in overwriting my default graphics that were created with the new project. I'll click Next, and once again I see a preview of all the files that are going to be created.
In addition to these launcher icons, I'm also going to get a file called ic_launcherweb.png. That won't be a part of the functional application, but it will be useful when I deploy the app through the Google Play Store. It'll be the right size and pixel density for the marketing graphic that the Google Play Store requires. I'll click Finish, and that overwrites my existing launcher icon graphics. And I see this updated immediately in Android Studio.
Then, I'll run the app again. After the app reloads, I'll test to make sure it's still functional. And then I'll close it. And then I'll see on my launcher screen, that my new launcher icon is displayed. And I'll open the app list, and I'll see it shown here as well. If I click and drag, I can drop another copy on the launcher screen or I can touch and hold that, and remove it.
So that's the easiest way to create a new launcher icon for your app. Again, you want it to be a visual representation of your app, that makes it uniquely identifiable to the user of the Android device.
- Installing and configuring Android Studio
- Creating virtual devices and connecting physical devices for testing
- Working with project files such as the app manifest and Gradle scripts
- Defining the user interface
- Modifying material design themes and styles
- Adding views
- Displaying messages
- Handling events and changes in screen orientation
- Displaying images
- Managing navigation with activities and layouts
- Supporting different screen sizes
- Working with data