为什么 Android Studio 在 res/drawable-v24 中创建 ic_launcher_foreground 并在 res/drawable 中创建 ic_launcher_background.xml?

ivy*_*the 6 icons android android-studio android-vectordrawable adaptive-icon

首先

我注意到在 Android Studio 中创建一个新项目时它会生成drawable-v24带有ic_launcher_foreground.xml图标的文件夹。

我的问题是:

  1. 如果在 v24 之前引入了vector drawable,那么为什么它将矢量资产drawable-v24放在drawable-v21文件夹中而不是放在文件夹中?

其次

另一个生成的资产是ic_launcher_background.xmlres/drawable文件夹中创建的,后来从mipmap-anydpi-v26/ic_launcher.xml.

  1. 如果它仅用于 API v26+(自适应图标),那么为什么它是在res/drawable文件夹中创建而不是在res/drawable-v24或 中res/drawable-v26?是由于 mipmap 文件夹的某些性质吗?

hat*_*ata 2

尽管 VectorDrawable功能是从 API-21 引入的,但它在某种程度上已集成到 API-24 中。我认为 Google 的开发人员认为 API-24+ 对于自适应图标来说是理想的或稳定的。

\n\n

例如,Nick Butcher(Android 设计师 + 开发者@Google)在他的文章:在 Android 应用程序中使用矢量资源(2018 年 12 月 11 日)中说道,

\n\n
\n
    \n
  • nonZero 和 EvenOdd 路径 fillTypes \xe2\x80\x94 定义形状内部的两种常见方法,经常在 SVG 中使用(evenOdd 添加到 API 24 中的平台实现中)
  • \n
  • 渐变和 ColorStateList 填充/描边(添加到 API 24 中的平台实现)
  • \n
\n
\n\n

而关于ic_launcher_background,它仅引用自mipmap-anydpi-v26/ic_launcher.xmlmipmap-anydpi-v26/ic_launcher_round.xml。我认为这只是没有必要阻止直接引用它(它已经通过放置ic_launcher.xmlandic_launcher_round.xml来阻止mipmap-anydpi-v26文件夹中来阻止)。不应该有更多、更深刻的含义。

\n