要在安装后使用它,请右键单击res / drawable文件夹并选择 New > Batch Drawable Import :
然后通过 + 按钮选择图像,并将分辨率设置为xxhdpi(或源图像的分辨率) .
7
I will try to explain the process in step wise basis, so that it will be simple to understand to anyone.
1. Go to Setting > Plugins
2.Search " Android Drawable Importer " in the search bar
3.It will not show the plugin by default, to search it online click in "Browse" Link
4.Then install the plugin , it will show downloading .... sometimes it may not show downloading, so make sure to check at the bottom of the android studio, it shows downloading.
5. Now restart android studio
6. As you can see in the following screencap, there is only one drawable here
7. now right click on drawable folder and navigate to New>Batch Drawable Import
9. Now select "the Single " image you want different variations of drawables.
10.Now select which dimension the origin image is. If the origin image is xxhdpi like in my case select "xxhdpi " as "Source Resoultion".
-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.
16 回答
我在Eclipse中使用了一个名为Android Icon Set的工具,用于标准图标,如Launcher,ActionBar,Tab图标和通知图标 . 您可以从文件 - >新建 - >其他.. - > Android - > Android图标集启动它 . 最好的部分是您可以从计算机中选择任何文件,它会自动将标准尺寸的所有图像放入项目目录中 .
选项#1:只需发送
-xxhdpi
drawables并让Android在运行时为您下采样(缺点:仅适用于最近的设备,其中-xxhdpi
已知) .选项#2:使用Android Asset Studio为您下采样 .
选项#3:根据ssantos的回答,在图形编辑器中自动完成该过程 .
选项#4:使用ImageMagick之类的东西为自己编写解决方案 .
选项#5:使用image baker
我使用名为
Android Drawable Importer
的Android Studio插件:要在安装后使用它,请右键单击res / drawable文件夹并选择
New > Batch Drawable Import
:然后通过
+
按钮选择图像,并将分辨率设置为xxhdpi(或源图像的分辨率) .I will try to explain the process in step wise basis, so that it will be simple to understand to anyone.
1. Go to Setting > Plugins

2.Search " Android Drawable Importer " in the search bar

3.It will not show the plugin by default, to search it online click in "Browse" Link

4.Then install the plugin , it will show downloading .... sometimes it may not show downloading, so make sure to check at the bottom of the android studio, it shows downloading.

5. Now restart android studio
6. As you can see in the following screencap, there is only one drawable here

7. now right click on drawable folder and navigate to New>Batch Drawable Import

9. Now select "the Single " image you want different variations of drawables.
10.Now select which dimension the origin image is. If the origin image is xxhdpi like in my case select "xxhdpi " as "Source Resoultion".
11.现在按OK然后再次确定..然后它将需要几秒钟然后你将神奇地获得drawables的所有变量 .

使用像Image Baker这样的在线服务 .
这很简单 . 上传图像并下载Android和iOS的已处理资源 .
根据CommonsWare的答案使用ImageMagick(转换)的bash脚本:
由于Kishan Vaghela添加了文件夹创建和参数检查
刚刚在新的Android Studio中找到了一种简单的方法:
我通常使用assets.codly.io
它在您的浏览器中本地生成资产,无需上传,无需下载 .
我认为Redwarp提供的工具是最好的! https://github.com/asystat/Final-Android-Resizer
在另一个问题中找到它:https://stackoverflow.com/questions/10754523/is-there-any-tool-which-can-a-resize-png-image-into-a-image-for-ldpi-mdpi-hdp
由于这是Google上的第一个结果,我想在此处添加此信息 .
我写了一个Photoshop脚本来从PSD文件创建ic_launcher png文件 . 只需检查ic_launcher_exporter .
要使用它,只需下载它并使用photoshop中的脚本 .
并配置您要生成输出文件的位置 .
我很幸运使用这个插件用于photoshop:
check here
有一些工作可以正确命名图层和按钮状态 . 但是,一旦你这样做,内置的宏是非常好的 .
否则,如果您有相关知识,可以在photoshop中编写自己的宏 .
不是100%自动,但我使用Photoshop Actions节省了大量时间 .
例如,给定
xhdpi
资产,然后我为hdpi
和mdpi
创建任务,分别扩展到66.66%和44.44% . 然后我对文件夹xhdpi
上的所有图像运行操作 .对于512x512图像,您所要做的就是计算缩放图像的百分比,以达到xxhpi,xhdpi,hdpi和mdpi .
只需使用https://romannurik.github.io/AndroidAssetStudio/index.html . 它可以从图像中制作一组图标,稍后您可以下载一个zip文件 .
或者在https://github.com/redwarp/9-Patch-Resizer/releases下载Windows应用程序(不需要安装)并打开图标 .
使用Android Studio图像资源
去:
然后设置:
选择:下一步>完成 .
编辑:我建议使用SVG图像来创建Vector Drawables,然后在画布中使用它们将它们调整到正确的大小或只是更改DP .
您可以从Google获取默认图标,也可以创建自己的图标
然后设置:
选择:下一步>完成 .
现在你将拥有你的图标,你将能够改变大小,颜色等 .

还可以将Vector Asset Studio与Scalable Vector Graphics (SVG)结合使用 . Android Studio将为您处理剩下的事情 . 正如official documentation所说:
我认为这是未来的方法 .
我在这里一直使用解决方案线程,它很容易使用插件 Android Drawable Importer
如果您在MacOS上使用Android Studio,只需尝试此步骤即可:
单击栏菜单 Android Studio 然后选择 Preferences 或点击按钮 Command + ,
然后选择 Plugins
点击 Browse repositories
在搜索列表中写入 Android Drawable Importer
单击 Install 按钮
然后显示对话框重启,只需重启Android Studio即可
安装插件成功后,要使用此插件,只需单击“创建新菜单”,然后选择 Batch Drawable Import . 然后单击加号按钮a.k.a添加按钮,然后选择您的文件以使其可绘制 . 然后只需单击确定,然后确定drawable已完成所有这些操作 .
如果你对我的话感到困惑,只需看看learningmechine的图像教程 .