Android NinePatch .png 文件格式?
Android NinePatch 图像似乎是标准 .png带有额外信息的文件。是否有任何地方的格式规范,因为我希望能够在其他平台上实现此格式?
Android NinePatch images seem to be standard .png files with extra information. Is there a spec for the format anywhere, as I'd like to be able to implement this on other platforms?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
只需在图像查看器中查看 9 patch 图像即可。它只是一个 1 像素的边框,可拉伸区域两侧有黑色像素,静态部分透明标记。
如果放大此图像,您可以看到标记可拉伸区域的黑色边框:
示例http://web6.twitpic.com/img/91916457-a53b6866db73378bda07c039151c69aa.4bd6119a-full.png
Just take a look at a 9 patch image in an image viewer. It's simply just a 1px border with black pixels flanking the stretchable areas and transparent marking the static parts.
If you zoom into this image you can see the black border marking the stretchable area:
example http://web6.twitpic.com/img/91916457-a53b6866db73378bda07c039151c69aa.4bd6119a-full.png
我强烈建议您不要在其他平台上实现 9patch 系统,原因有几个。
我已经使用 Android 的开发者工具一年了,并且广泛使用了 9patch 文件。
他们是一场噩梦。 PNG不是一种数据格式,它是一种图像格式。在 .9.png 文件中混合两者会带来麻烦。
9patch 文件不是一个好主意,因为它们将图像和数据格式合并到一个文件中,设计者和开发人员都无法完全管理该文件。
九个补丁文件:在维护、支持和更新阶段的某个时刻,您会后悔自己的参与。
或许,如果在未来的某个日期,对 9patch 文件的支持被添加到许多质量工具中(例如,PS CS4 不将 9patch 文件理解为特定格式,也不遵守有效的九个补丁格式的规则。
)用于九个补丁文件的工具很糟糕——在我雇用的大多数设计师看来基本上无法使用。
I would strongly suggest that you not implement the 9patch system on other platforms, for several reasons.
I have been using Android's developer tools for a year and have made extensive use of 9patch files.
They are a nightmare. PNG is not a data format, it is an image format. Mixing the two in the .9.png file is asking for trouble.
9patch files are a poor idea because they combine image and data formats into a single file that is neither fully manageable by a designer nor a developer.
Nine patch files: you will regret your involvement at some point during maintenance, support and updates phase.
Perhaps if at some future date support for 9patch files is added to a number of quality tools (for example, PS CS4 doesn't understand 9patch files as a specific format, nor does it honor the rules of valid nine patch formats.)
The existing tools for nine patch files are awful -- essentially unusable in the opinion of most designers who I have hired.
此链接对于 android 中的九个补丁图像非常有用。
这是android中非常有用的例子。仅使用 .9 补丁 PNG 文件。
http://blogingtutorials.blogspot.com/2010/12/android -九-补丁-example.html
This Link is very useful for nine patch image in android.
It is very useful example in android. Only use .9 patch PNG file.
http://blogingtutorials.blogspot.com/2010/12/android-nine-patch-example.html
现代浏览器支持基于 CSS 9 路径的背景:
http://www.css3.info/preview/border-image/
Modern browsers support CSS 9-path based backgrounds:
http://www.css3.info/preview/border-image/
我发现此链接非常有用:博客文章链接。它使用一些示例来说明创建 9 补丁时定义的不同边界。它显示了如何使用额外信息来缩放图像尺寸 (x,y)。
最后甚至还有 Richard L. 的精彩评论,其中说明了如何通过在边框中添加中断来添加要防止缩放图像的区域;例如。不缩放图像中的部分。
I found this link to be very useful: link to blog post. It uses some examples for the different borders defined when a 9 patch is created. It shows how the extra information is used in scaling the images' dimensions (x,y).
There is even a nice comment by a Richard L. at the end which says how you can add regions to be protected from scaling the image by including breaks in the borders; eg. not scaling sections in the image.
我花了一段时间才明白9补丁文件的扩展名应该是xxxx.9
而不是 xxx.9.png
Took me a while to understand that the Extension of the 9 patch file should be xxxx.9
and not xxx.9.png
这是我见过的最直接的链接发现有关该主题的内容。
This is the most straightforward link I've found on the subject.