Android: Adaptive Icons

With the release of Android 8.0 (API level 26) Android introduces adaptive launcher icons, which can display a variety of shapes across differnet device models.


For example, An adaptive launcher icon can display a circular shape on one OEM device, and display a squircle on another OEM device. Each device OEM (Original Equipment Manufacturers) provides a mask, which the system then uses to render all adaptive icons with the same shape.
These adaptive icons are intended to provide a more consistent look and feel across the device’s launcher.

You can control the look of adaptive launcher icon by defining two 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.

Creating Adaptive Icons in XML

To add an adaptive icon to an app using XML, begin by updating the android:icon attribute in your app manifest to specify a drawable resource.

<application
    …
    android:icon="@mipmap/ic_launcher"
    …>
</application>


Each adaptive icon consists of a background layer, foreground layer, and a mask. The mask is provided by the OEM, but you’ll need to provide the background and foreground layers.
These layers should be PNGs without any masks or background shadows. Both layers must be 108x108 dpi, but the inner 72x72 dpi is the content that’ll appear within the masked viewport, as the system reserves the outer 36 dpi around the icon for visual effects, such as pulsing or parallax.

Next, create a res/mipmap-anydpi/ic_launcher.xml file and use it to reference the two drawables you want to use as your background and foreground layers.
for example:

<?xml version="1.0" encoding="utf-8"?>
  http://schemas.android.com/apk/res/android">
      <foreground android:drawable="@mipmap/ic_foreground"/>
      <background android:drawable="@mipmap/ic_background"/>
  </adaptive-icon>

You can also define an icon drawable resource using the android:roundIcon attribute. You must only use the "android:roundIcon" attribute if you require a different icon asset for circular masks, For example the branding of your logo relies on a circular shape. The following code snippet illustrates both of these attributes:

  <application
    …
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    …>
</application>
Thanks,

Refrence:

https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive.html

Comments

Popular posts from this blog

Understanding Top line and Bottom line?

How to activate PF UAN account

Scrum Master vs Product Owner