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

标签 android android-studio icons android-vectordrawable adaptive-icon

首先

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

我的问题是:

  • 如果 矢量图 s 是在 v24 之前引入的,那么为什么它会将矢量 Assets 放在 drawable-v24 中而不是 drawable-v21文件夹?


  • 其次

    另一个生成的 Assets 是 ic_launcher_background.xml创建于 res/drawable文件夹,后来被 mipmap-anydpi-v26/ic_launcher.xml 引用.
  • 如果它仅用于 API v26+ ( adaptive icons ) 那么为什么它是在 res/drawable 中创建的文件夹而不是 res/drawable-v24或在 res/drawable-v26 ?是由于 mipmap 文件夹的某些性质造成的吗?
  • 最佳答案

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

    比如Nick Butcher(Android设计师+开发者@Google)在他的文章中说:Using vector assets in Android apps (2018 年 12 月 11 日),

    • 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)


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

    关于android - 为什么 Android Studio 在 res/drawable-v24 中创建 ic_launcher_foreground 而在 res/drawable 中创建 ic_launcher_background.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57326843/

    相关文章:

    android - 检索 firebase 字段的父项和子项

    android - 如何在跳过循环后调试 for 循环

    python - 如何通过 WxPython 使用标准工具栏图标?

    java - Google map V2 Android 的 API key 显示为空白

    android - 以编程方式构建 LinearLayout

    android - 如果我的应用程序在我的 Android Studio 模拟器上运行缓慢,它会在设备上运行缓慢吗?

    c - 图标大小帮助 WINAPI 只显示小 c

    ios - 快速为常规按钮提供条形按钮标识符

    java - 从 AsyncTask 填充的 ListView 不会呈现

    android - 当播放不止一种声音时如何停止媒体播放器?