Meaning of red color in Android's Nine-patch drawables-ThrowExceptions

Exception or error:

According to the Android documentation, we know that the left and top black line define the stretchable area, and the bottom and right line define the content area.

It’s easy to understand, but I found the below image named textfield_activated_holo_dark.9.png from android-17 framework. What is the purpose of the red colors in the lower-left, lower-right and top-right corners?

enter image description here

How to solve:

I believe this thread has some discussion on the same topic.

This has got something to do with setting layout bounds and I believe its not documented yet.


It’s too support layout bounds.

See for more info.


The red lines are how you define optical bounds on a nine-patch. This feature was officially added in Android 4.3 but to date, its still not available in the support library. Read more about them in the 4.3 release notes:


If you are using optical bounds, you should take in account a little bug introduced with gradle 0.9.1 plug-in, For a work around First in this issue report: In this you can see that using gradle plug-in 0.9.1 makes PNG crash on GB and it states that the work around is use 0.9.0 instead. But that not nice either, in the release notes of 0.9.1 the android team states that you should use the old PNG cruncher:

I have test both solutions and both are OK, i thing the second one is better, its your choice

Leave a Reply

Your email address will not be published. Required fields are marked *