Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android Studio create the ic_launcher_foreground in res/drawable-v24 and the ic_launcher_background.xml in res/drawable?

Firstly

I noticed when creating a new project in Android Studio it generates drawable-v24 folder with ic_launcher_foreground.xml icon.

And my question is:

  1. If vector drawables were introduced before v24 then why does it put the vector asset in drawable-v24 and not in drawable-v21 folder?

Secondly

Another generated asset is ic_launcher_background.xml which is created in res/drawable folder and was later referenced from mipmap-anydpi-v26/ic_launcher.xml.

  1. If it is only used in API v26+ (adaptive icons) then why was it created in res/drawable folder and not in res/drawable-v24 or in res/drawable-v26? Is it due to some nature of mipmap folders?
like image 317
ivy_the Avatar asked Aug 02 '19 12:08

ivy_the


People also ask

What is adaptive icon in Android?

An adaptive icon, or AdaptiveIconDrawable , can display differently depending on individual device capabilities and user theming. Adaptive icons are primarily used by the launcher on the homescreen, but can also be used in shortcuts, the Settings app, sharing dialogs, and the overview screen.

What is drawable folder in Android Studio?

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.

What file type is used for the launcher icon foreground and background vectors?

svg files for icons and then select local svg option in your vector asset creator to use it in your app.

Is Android roundIcon required?

You must only use the android:roundIcon attribute if you require a different icon asset for circular masks, if for example the branding of your logo relies on a circular shape.


1 Answers

The VectorDrawable feature is somewhat integrated in API-24 though it was introduced from API-21. I think Google's developers think API-24+ is ideal or stable for adaptive icons.

For example, Nick Butcher (Android designer + developer @ Google) said in his article: Using vector assets in Android apps (Dec 11, 2018),

  • Both nonZero and evenOdd path fillTypes —the two common ways of defining the inside of a shape, often used in SVGs (evenOdd added to platform impl in API 24)
  • Gradient & ColorStateList fills/strokes (added to platform impl in API 24)

And about ic_launcher_background, it is referenced only from mipmap-anydpi-v26/ic_launcher.xml and mipmap-anydpi-v26/ic_launcher_round.xml. I think it is just that there is no need to prevent from referencing it directly (It has already prevented by placing ic_launcher.xml and ic_launcher_round.xml in mipmap-anydpi-v26 folder). There should be not so far more, deep meanings.

like image 75
hata Avatar answered Sep 19 '22 17:09

hata