I am trying to use a 9-patch as background for a TextView, but it is treated as normal image file. According to the 9-Patch tool and the Intellij IDEA Layout Preview it should stretch properly though. I am using other 9-patches as well, so the problem can't be due to a misconfiguration of my system (e.g. missing library like in another case).
Checklist of what I've done so far:
Here is the image I'd like to use.
Just now I saw the IDE throwing this "information" at me: "ERROR: 9-patch image ...\res\drawable\timeline.9.png malformed. Too many rows and columns in 9-patch perimeter."
Are there any restrictions on the 9-patch I am not aware of? Tried searching the documentation for more information about that, but without success.
Thanks in advance, /me
P.S.: I know the image could be optimized by removing the extra space within the segments, but that's sth. I planned on doing once it is working as expected.
With 2 horizontal markers I was able to use 12 vertical markers (adding one more vertical or horizontal marker will give that error). So I think it counts the intersection (H * V), maximum might be 25 based on other answers.
Update:
Based on android code:
// Make sure the amount of rows and columns will fit in the number of
// colors we can use in the 9-patch format.
if (numRows * numCols > 0x7F) {
errorMsg = "Too many rows and columns in 9-patch perimeter";
goto getout;
}
The maximum value is 0x7F = 127.
A vertical marker is considered as one column, while horizontal marker is one row. so if you have 5 markers in each then it means you have 5 stretchable columns + 6 un-stretchable columns (the areas between the markers) so total of 11 vertical and same for horizontal so 11 * 11 = 121 which is less than 127 so you are good
in my case i had 12 vertical (12+13 =25) and 2 horizontal (2+3 =5) so 25*5=125 still less than 127.