开发者

Android What is wrong with this 9 patch?

开发者 https://www.devze.com 2023-02-15 21:48 出处:网络
Hello, see above for my开发者_运维百科 9 patch image. It is created using the 9 patch editor from Android tools. I have multiple issues:

Android What is wrong with this 9 patch?

Hello,

see above for my开发者_运维百科 9 patch image. It is created using the 9 patch editor from Android tools. I have multiple issues:

  • The nine patch tool in preview scales the image in height as well. Why? Zhere is no black line on the left.
  • The nine patch tool shows bad patches. I think that means that I still can use it but it might not look good. Is there any simpler shape than this? What goes wrong when stretching?
  • I cannot import this 9.png file into my project without errors. So technically there must be something wrong.

Thanks, A.


Seems like both top and left lines are required by 9-patch to determine the stretchable area. You could put one pixel there. You could later fix the height of the view which uses this image to prevent it from stretching in height.


You need to add stretch information for height too. A nine patch should be stretchable both horizontal and vertically.

The bad patches are warning of artifacts may be produced when stretching. Try deleting stretch above the green/white transition of your image.

I think the missing vertical stretch is why you get error, assuming it is has the extension 9.png.

Tips for enhancing you nine patch: By the looks of your image you have included the right border as stretchable too, you might want to remove that. Consider only having 3 pixels stretch above the green content, then 1px above the white content to keep the aspect ratio. There is no need to stretch the whole image. You need only 1px transparent padding from image to stretch data.

0

精彩评论

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