开发者

9 patch drawable

So here's my image:

9 patch drawable

The problem is, draw9patch can't create normal 9 patch from this (shows errors in padding). Neither does android scale it correctly if I create 9 patch manually, like so:

9 patch drawable

I believe that it's a color issue, that android sees the borders of my original image as a part of 9 patch paddings and thus, scales incorrectly.

Is there a way, to create a 9 patch from this?

Thanks in advance :)

EDIT

There must be NO extra empty border aro开发者_StackOverflow社区und original image, or it will persist and will have a white lines around it. There must be 1 extra pixel added to every side of the raw image to contain 9 patch paddings, so if the original width was 50px, it will be now 52 px. It's not the first time I'm making a nine patch< just this time it doesn't work. If you don't believe me, try and do it in draw9patch.bat and you'll see that it doesn't add extra border at the top and shows error even on the original image.

EDIT Ok. NVM, just had to make raw image a bit wider. Now it scales right,


Works just fine for me, just add a dot at the top for the horizontal stretch position, then a line along the left-hand side for the vertical stretch position:

9 patch drawable

9 patch drawable

EDIT: Added the second option, still seems to work fine.


It's hard to see something in such a little image, but this one doesn't seem to be right.

black pixels delimiting stretchable area and padding box must be 1 pixel away of border and stretcheble area is mandatory (top and left borders), in the image you provide, these borders seems not to be separated from the graphic.

Please refer to the docs for the right way of using 9-patch graphics

About the problems with draw9patch tool, wich errors is throwing and when? Maybe if you make input image a little wider it works


You need to have a border of 1px around the image in order to get it to a correct 9patch-png. Also you should know what happens when you place a black pixel on any of the sides.

  • Top and left side: scaling of the image.
  • Bottom and right side: content inside the scaled image for placing your stuff.

You also should consider where you need to place your "black pixels".

The pixels in the very corner of your 9patch-png must not be black.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜