gpt4 book ai didi

Android MipMap - 如何在 XML 中创建图像资源

转载 作者:行者123 更新时间:2023-11-29 15:48:01 25 4
gpt4 key购买 nike

一段时间以来,我注意到 Android Studio 在项目目录中有“mipmap”文件夹。据我了解,为了确保我们在所有设备(应用程序图标)之间具有图像资源的一致性,我们应该拥有 XML 格式的图像资源,如下所示:

    <!-- drawable/numeric-1-box.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#757575"
android:pathData="M14,17H12V9H10V7H14M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z" />
</vector>

我一直在使用 Material Design Icons站点以获取 XML 格式的大部分通用图标。但是,我该如何着手创建这样的图标呢?到目前为止,我一直在从上面显示的站点下载它们。是否有可用于将图像导出为这些格式 (XML) 的工具?这样做的程序是什么? Photoshop、Illustrator 或其他图像转换网络工具?将不胜感激有关如何创建这些图像的任何帮助。

最佳答案

I've noticed for a while now that Android Studio has "mipmap" folders in the project directory.

请注意,这与您问题的其余部分中的任何其他内容无关。矢量绘图将进入 res/drawable-nodpi/ , 不是 mipmap目录。

From what I understand, in order to make sure we have consistency of image resources across all devices (in-app icons) we should have image resources in XML format such as the one shown below:

仅当您的 minSdkVersion为 21 或更高,或者如果您使用的库提供向后移植 VectorDrawable . Android 1.0 到 4.4 不支持 <vector>可绘制对象。

how do I go about creating icons like these?

我将从创建代表您的图标的 SVG 文件开始。您可以使用 Inkscape 等工具在本地使用 SVG,其他图形工具(例如 Adob​​e Illustrator)可以导出为 SVG。 <path>您在该 XML 中看到的内容基于 SVG 路径规范。

从那里,您可以创建 <vector>可绘制 manually或使用 tools执行 SVG-> VectorDrawable转换。

关于Android MipMap - 如何在 XML 中创建图像资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31777453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com