为什么Android的点9图四周的颜色只能是白、黑或透明

来源:互联网 发布:windows 10 恢复桌面 编辑:程序博客网 时间:2024/04/29 00:01

http://androidren.com/index.php?qa=363&qa_1=%E4%B8%BA%E4%BB%80%E4%B9%88android%E7%9A%84%E7%82%B99%E5%9B%BE%E5%9B%9B%E5%91%A8%E7%9A%84%E9%A2%9C%E8%89%B2%E5%8F%AA%E8%83%BD%E6%98%AF%E7%99%BD-%E9%BB%91%E6%88%96%E9%80%8F%E6%98%8E

这个问题,首先要从点9图的官方设计原理和说明来释疑。
官网说明:
http://developer.android.com/intl/zh-cn/guide/topics/graphics/2d-graphics.html#nine-patch
The border is used to define the stretchable and static areas of the image. You indicate a stretchable section by drawing one (or more) 1-pixel-wide black line(s) in the left and top part of the border (the other border pixels should be fully transparent or white).
首先,官方文档已经说明,只有黑、白或透明三色可以作为边界的颜色存在。
其次,点9图的设计就是需要指定一种或几种颜色来表达拉伸和显示控制。而黑色、白色和透明是最简单的方法。
再次,编译点9图的时候,编译工具会根据点9图设计原理来检查不符合规定的颜色(黑、白和透明)。
 
题外话,如果是你设计点9图,你把这个设计成屎黄色也可以。但,真的有必要这么个性吗?黑色、白色的数值是0或者1,肯定比你那个屎黄色更方便计算和处理。

0 0
原创粉丝点击