问题
I have a 9-patch image. I defined top left quadrant to be a content area, yet it is not honoured (see the preview on the right hand side of the screenshot). What am I missing? Thanks!
回答1:
The content region is defined by the right and lower bars as mentioned above, but what you are really defining is the padding (top,left,bottom and right padding).
The padding is set by counting the number of transparent pixels at the start and end of the right and lower bars. So the padding would be approx 10,10,40,40 (t,l,b,r) if your image was 100x100.
When the image is stretched, the padding doesn't change and since it is measure from each edge, that explains why the content area stretches the way it does.
回答2:
Your content area, defined by the right and lower black bars, is fully contained in the stretchable region, defined by the upper and left black bars. Hence the content region will also be stretched, this is intended.
来源:https://stackoverflow.com/questions/20961745/android-nine-patch-content-border-not-honoured