简体   繁体   English

使用矢量 drawable 作为 Android 应用程序图标

[英]Using vector drawable as Android app icon

After creating an Android Studio 'Phone and Tablet' project using Material3 for Jetpack Compose, there appears to be a superfluous amount of image files created, despite the minimum API being 30 (Android 11).在使用 Material3 for Jetpack Compose 创建 Android Studio“手机和平板电脑”项目后,尽管最低 API 为 30(Android 11),但似乎创建了过多的图像文件。 Why in the mipmap folder has a whole bunch of raster images been generated, when for years, developers have been encouraged to use vector drawables for their app icons?为什么在mipmap文件夹中生成了一大堆光栅图像,而多年来,开发人员一直被鼓励在他们的应用程序图标中使用矢量可绘制对象? Even the XML files seem to be in a folder for API 26. Is that really necessary when an app targets API 30?甚至 XML 文件似乎都在 API 26 的文件夹中。当应用程序以 API 30 为目标时,这真的有必要吗? What should be done with the files in the ic_launcher and ic_launcher_round folders ending in .webp ?应该如何处理以 .webp 结尾的ic_launcheric_launcher_round文件夹中的.webp

AndroidManifest.xml AndroidManifest.xml

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.MyApp"
    tools:targetApi="31">
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:theme="@style/Theme.MyVectorApp">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

'Project' pane in Android Studio Android Studio 中的“项目”窗格

在此处输入图像描述

  1. WebP is an image format that is developed by Google, focuses mainly on optimization and quality, more on that here WebP 是 Google 开发的一种图像格式,主要关注优化和质量,更多内容在这里
  2. those generated images are pretty necessary, because they allow the apps icon to adapt to screen size, as shown here这些生成的图像非常必要,因为它们允许应用程序图标适应屏幕大小,如下所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM