为不同 dpi 创建可绘制对象的最佳方法是什么
您是先创建 MDPI 可绘制对象,然后在 Photoshop 中将其按像素比例缩放到 0.075/1.00/1.50/2,还是重新创建每个单独的可绘制对象?
另外,是从高质量图像开始并开始缩小它还是从 MDPI 图像开始然后放大它更好?
这就是我所做的:
在 Photoshop 中创建一个 320x480 比例和 160 分辨率的 mdpi 图像。只需输入 120,160、240 或 320 作为分辨率即可保存 4 个图像并更改分辨率。
Do you create the MDPI drawable first and just scale it accordinly to the .075/1.00/1.50/2 ratio by pixels in photoshop or do you recreate each individual drawable?
Also is it better to start with a high quality image and start scaling it down or start with a MDPI image and just scale it up?
Here's what i do:
Create a mdpi image in photoshop with 320x480 porportions and 160 as it's resolution. Save 4 images and changing the resolution by simply entering 120,160, 240, or 320 as the resolution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
来自Android设计指南:
有关此主题的更多详细信息,请查看支持多个屏幕。
From the Android design guidelines:
For more detailed information on this topic, check out Supporting Multiple Screens.
图标设计指南的设计人员提示部分有以下建议:
该部分还有许多其他不错的提示。我认为这对于其他可绘制类型(菜单图标、背景等)也是很好的建议。
The tips for designers section of the Icon Design Guidelines has the following advice:
There are a number of other nice tips in that section. I think it's good advice for other drawable types as well (menu icons, backgrounds, etc.).
我通常从大开始,然后逐渐变小。
我发现 powerpoint 实际上是一个非常好的工具,可以为我的应用程序创建资源。所有图形都是矢量,因此它们可以按比例放大和缩小,而不会造成任何质量损失。
如果没有其他原因,我倾向于从大的开始,因为使用看起来更大的东西更容易。当我转向较小尺寸的尺寸时,我通常会放大一些以进行补偿。
Powerpoint 中的任何图形对象都允许您右键单击它并选择“另存为图片”,这会将其输出为 png 文件。剩下的唯一一件事就是如果需要的话将其放入draw9patch中。
I generally start big, and move to smaller.
I find that powerpoint is actually a very nice tool for creating resources for my applications. All of the graphics are vector, so they scale up and down without any quality loss.
I tend to start with the big ones if for no other reason than it is easier to work with something that looks bigger. when I move to the smaller sized ones I generally zoom in some to compensate.
Any graphic object in powerpoint will allow you to right click it and choose "Save as picture" which will output it as a png file for you. Only thing left is to drop it into draw9patch if need be.
我使用 Inkscape,也处理矢量图像,然后导出到各种分辨率所需的光栅大小。我写的关于从 Inkscape 生成图标的文章可以在 https://tekeye 找到.uk/android/android-launcher-icons-using-inkscape
I use Inkscape, working with vector images as well, then export to the required raster size for the various resolutions. An article I wrote on producing icons from Inkscape can be found at https://tekeye.uk/android/android-launcher-icons-using-inkscape
最好的方法:创建高分辨率图像,然后缩小它们。
如果你使用Photoshop,这将是小菜一碟!
我的分叉版本输出Android Assets.jsx 脚本自动执行所有 dpi 的缩小过程 :-)
只需单击一下,它将创建:
。因此,只需创建 xxxhdpi 图像,然后使用脚本将其缩小。
将初始高分辨率图像宽度和高度创建为 16 的倍数是明智的,因为它们会正确缩小,如下表所示:
希望这会有所帮助
注意:< /strong>
tvdpi 是一种罕见的情况,所以我并不真正关心它有时会缩小到“无整数”值。
鸣谢:
此脚本的先前版本(我添加了 xxxhdpi 和 xxhdpi 支持)可使用 这里
和此处
Best way: create high res images, then downscale them.
If you use Photoshop, it will be a piece of cake!
My forked version of Output Android Assets.jsx script automate the downscale process for all dpi :-)
In one click, it will create:
So, just create xxxhdpi images then scale them down with the script.
Creating initial high res images width and height as a multiple of 16 is wise since they will scale down properly as illustrate in this table:
Hope this helps
Note:
tvdpi is a rare case, so I don't really care about it sometimes scaling down to "no integer" values.
Credits:
Former versions of this script, to which I added xxxhdpi and xxhdpi support, are available here
and here
我建议在 powershell 中为 Inkscape 编写一个小脚本。
示例:
将 Inkscape 放入“c:\bin\inkscape”(目录中没有任何空格),并以 mdpi (1x) 分辨率绘制所有图像。
在 Inkscape 对象属性框中(即 xml 中的 id),为要以 png 格式导出的每个对象指定一个 ID 名称。
将 SVG 保存到“C:\users\rone\Pictures\design-MyApps-forscript.svg”
创建一个目录“d:\temp”。
并将此脚本放入“C:\app\scripts\”
Powershell 脚本名称为“inkscape_to_png.ps1”:
现在,将此脚本称为此示例:
@(“btn_button_name_1”,“btn_button_name_3”,“btn_other”, “btn_zoom”,“btn_dezoom”,“btn_center”, “btn_wouwou”,“im_abcdef”,“ic_half”,“ic_star”,“ic_full”)| % { C:\app\scripts\inkscape_to_png.ps1 -img $_ -f design-MyMap-forscript.svg }
该脚本将以所有分辨率(ldpi、mdpi、hdpi、xhdpi、 xxhdpi, xxxhdpi) in d:\temp\drawable-xyz ...
所以节省了很多时间。
I suggest a little script write in powershell for Inkscape.
Example :
Put Inkscape in "c:\bin\inkscape" (dir without any space) and draw all your images in mdpi (1x) resolution.
in Inkscape object properties box (i.e id in xml), give an Id name for each object that you would to export in png.
Save your SVG to " C:\users\rone\Pictures\design-MyApps-forscript.svg"
Create a dir "d:\temp".
And put this script in "C:\app\scripts\"
Powershell script name is "inkscape_to_png.ps1" :
now, call this script as this example :
@("btn_button_name_1","btn_button_name_3","btn_other", "btn_zoom", "btn_dezoom", "btn_center", "btn_wouwou", "im_abcdef", "ic_half", "ic_star", "ic_full") | % { C:\app\scripts\inkscape_to_png.ps1 -img $_ -f design-MyMap-forscript.svg }
And the script will create all your drawables in all resolutions (ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) in d:\temp\drawable-xyz ...
So a confortable time saving.
从 Android L 开始,有一个 VectorDrawable,它类似于 SVG 中的 SHAPE,但采用 Android 的 XML 样式,
请参阅 Android 文档:
https://developer.android.com/training/material/drawables.html#VectorDrawables
As of Android L there is a VectorDrawable which is like the SHAPE from SVG but in Android's XML style
see Android documentation:
https://developer.android.com/training/material/drawables.html#VectorDrawables
看起来Android Studio中有一个工具:
在“项目视图”>“展开你的项目文件夹”右键单击应用程序>新的>图像资源
图标类型:操作栏和选项卡图标
资源类型:图像
选择原始图像的路径(应该很大)
形状:无(使背景透明)
并且它将在适当的可绘制文件夹中生成图像。
Looks like there's a tool in Android Studio:
Expand your project folder in the Project View > right click on app > New > Image Asset
Icon Type: Action Bar and Tab Icons
Asset Type: Image
Choose the Path for original image (it should be big)
Shape: None (to make background transparent)
And it will generate the images in the appropriate drawable folders.