是否有一种方法来创建xxhdpi, xhdpi, hdpi, mdpi和ldpi绘制从一个大规模的图像自动?例如,假设我有一个512x512的图像,我想在适当的文件夹中有这个图像的不同版本,用于Android支持的不同屏幕分辨率。


当前回答

在新的Android Studio中找到了一个简单的方法:

其他回答

Just use https://romannurik.github.io/AndroidAssetStudio/index.html. It can make a set of icons from an image, later you can download a zip-file. Or download a Windows application at https://github.com/redwarp/9-Patch-Resizer/releases (doesn't need to install) and open an icon. Also you can use a plugin Android Drawable Importer, see answers above. Because it is abandoned, install forks. See Why does Android Drawable Importer ignore selection in AS 3.5 onwards or https://github.com/Vincent-Loi/android-drawable-importer-intellij-plugin. https://appicon.co/#image-sets.

Android中一个简单的插件就能帮到你 步骤1。进入设置 步骤2。点击插件 步骤3。搜索Android Drawable Importer 步骤4。安装插件并重新启动

如何使用?

进入“文件>新建>批量可绘制导入”

享受

在新的Android Studio中找到了一个简单的方法:

选择#5:使用图像面包师是片状的。我转换了两张图像,它就停止了。 我成功地转换了10张图片:https://nsimage.brosteins.com/

使用Android Studio图像资产

至:

 Project>res --> right click

 new> image asset

然后设置:

-Icon type: Launcher Icons
-Asset type: Image
-Path: the/path/to/your/image
-Trim: No
-Padding: 0%
-Shape: None
-Effect: None

选择:Next > Finish。

Now you will have your icon in the correct resolutions.

编辑:我建议使用SVG图像来创建Vector Drawables,然后在画布中使用它们来调整它们的大小,或者简单地更改DP。

您可以从谷歌获取默认图标,也可以创建自己的图标

 Project>res --> right click
 new> vector asset

然后设置:

-Asset type: Local file (SVG, PSD)
-Path: the/path/to/your/image
-Size: check Override to keep your aspect ratio.
-Chek enable auto mirroring for RTL Layout.

选择:Next > Finish。

现在你将有你的图标,你将能够改变大小,颜色等。