Reputation: 280
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:
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
.
res/drawable
folder and not in res/drawable-v24
or in res/drawable-v26
? Is it due to some nature of mipmap folders?Upvotes: 8
Views: 4055
Reputation: 1991
A codelab answers your questions.
Depending on the min SDK of your app, you may notice that the foreground asset is located in the drawable-v24 folder, while the background asset is in the drawable folder. The reason is because the foreground asset contains a gradient, which was available starting in the Android 7.0 release (also known as API version 24, hence the -v24 resource qualifier). The background asset doesn't contain a gradient, so that can go in the base drawable folder.
As a side note, though we generally don't use ic_launcher_background.xml
for any purpose other than the app icon, it is just a vector drawable and its usage is not limited.
Upvotes: 2
Reputation: 12483
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.
Upvotes: 2