Adaptive icons are introduced in Android 8.0 (API level 26). In this new API level, the launcher icons can be displayed in a variety of shapes like circular, square etc. For example – according to icons type selected, your app’s launcher icon can be circular in one device and square in another device. Actually, the device provides a mask which is used to show the icons in different sizes.
Let us learn about creating Adaptive icons that fit in all the shapes and sizes.
You can control the look of your adaptive launcher icon by defining 2 layers, consisting of a background and a foreground. You must provide icon layers as drawables without masks or background shadows around the outline of the icon.
According to Android Developers documentation, the rules for creating the two layers are
- Both layers must be sized at 108 x 108 dp.
- The inner 72 x 72 dp of the icon appears within the masked viewport.
- The system reserves the outer 18 dp on each of the 4 sides to create interesting visual effects, such as parallax or pulsing.
To create an Adaptive icon you can follow the below given steps.
- Define the “icon” attribute in the application tag in your AndroidManifest.xml to specify a drawable resource.
12345<application…android:icon="@mipmap/ic_launcher"…></application> - Create an ic_launcher.xml in your mipmap folder. The file should look like this
1234<adaptive-icon><background android:drawable="@color/ic_background"/><foreground android:drawable="@mipmap/ic_foreground"/></adaptive-icon>
Adaptive icons are also animated according to the supported launchers. If you are still using legacy icons then the icon doesn’t look consistent with other icons that the system UI displays, and doesn’t support visual effects.
That’s all, create your own Adaptive icons to support the latest version of Android.
Thank you very much. This is Vedesh Kumar signing off.