Why is this a bad PNG for 9-patching?

It seems that every attempt to create a 9-patch file created a situation where the “content” in the Draw 9-patch was always “Bad”. Here is my last (and very simple) PNG that displays like all the bad pixels:

Bad PNG Content

Can I find out why this is “bad”? And how do I know what is good or what is bad if Android does not explicitly set any criteria in the SDK docs?

+4
source share
3 answers

This PNG is beautiful. What you have to do with the draw 9-patch tool is to select areas that you can stretch. Do not select a two-pixel area where your two colors meet. Here is the 9 patch that I created from your PNG:

9-patch

+3
source

It looks like your image does not have a 1-pixel border around the definition of the stretchable area and (optionally) the content area. This boundary is a requirement. Criteria for 9 patches are discussed in the Canvas and Drawables document. There's also a Draw 9-patch tool to help you draw 9-patch.

+2
source

Invalid color map of your bitmap:

correct.9.png: PNG image data, wxh, 8-bit/color RGBA, non-interlaced buttonbg.9.png: PNG image data, 6 x 21, 1-bit colormap, non-interlaced 
0
source

Source: https://habr.com/ru/post/1382363/


All Articles