What's mipmap-anydpi-v26 in res directory in Android Studio 3.0?

Viewed 41006

In Android Studio 3.0, once we create a project, a folder named mipmap-anydpi-v26 is automatically created in the res directory. What actually does it do? Why do we need it? How will we utilize it for development purposes?

Also, there are two XML files automatically created in this folder after project setup. Why do these XML files reside in a mipmap folder? I thought we should keep all XML files in a drawable folder instead of mipmap.

3 Answers

Both answers above give pretty good summary of what mipmap-anydpi-v26 folder does but I feel why part is missing. So heres my 2 cents.

anydpi: These resources take precedence in any dpi. So even if you have mipmap-hdpi or mipmap-mdpi matching with current devices density, resource from mipmap-anydpi will always be picked up.

anydpi-v26: This is an additional filter over just anydpi. This says resources will always be picked up from anydpi-v26 regardless of devices density only if SDK/API level is 26 or higher(Oreo).

So you can have mipmap-anydpi-v26 or drawable-anydpi-v26. All resource folders will follow above logic.

Now that we know the answer of "why mipmap-anydpi-v26"? lets try to understand why "mipmap-anydpi-v26/ic_launcher.xml".

This is because ic_launcher.xml is used to describe adaptive icon for your app which is only available in SDK 26 and up as mentioned by other answers. Hope this helps.

Related