How to create 9 patch in Photoshop? What is 9.png encoding? [closed]

倖福魔咒の 提交于 2019-12-02 18:21:25

Yes, I do all of my nine patches in Photoshop. Here are the basic rules for creating a 9-patch:

  1. The outer 1px margin can contain only 100% black (RGB 0, 0, 0) or fully transparent.

  2. The black pixels for the top margin and left margin define the stretch points, and must be either a solid line, a single point, or two separate points. If two points are defined, it will stretch equally between the two.

  3. The black pixels for the bottom margin and right margin define the content area. These pixels must be one contiguous line.

  4. When saving, be sure to append the .9.png extension.

Hope this helps. :)

EDIT: And yes, those will not be displayed when used in your layouts, provided it's properly formatted and you've saved it as a .9.png.

Okay, so the top would be a simple nine patch for a spinner. the lines across and down in the second image show which rows/columns of pixels would be duplicated. The blue rectangle in the second image shows the area in which Android would allow content to be placed. So text, for example, would simply wrap to stay inside this rectangle.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!