Search code examples
androidnine-patch

Android 9patch software help needed


I am trying to create a nine patch drawable. I created an image with a white border and then opened it in Draw9patch software as explained here:

I don't understand what I am supposed to do. I drew some kind of black border around it, and it gives me errors when I try to us it in my app. I have tried to draw a red border around it and it also gives the same errors that the nine patch is not valid.

Sometimes the area of the nine patch shows in pink and sometimes in green. I don't understand what it means and nothing is explained anywhere.

  1. If the nine patch is not valid how can I know (before compiling the app of course!)?
  2. Do you know of any good tutorial for nine patch, explaining more then only how to open nine patch software?

Solution

  • There is nothing complicated in 9Patch image let me explain you via example(image) enter image description here

    Top and Left parts are stretchable area, this part will increase when your screen size increase

    You can see pink dotted box in the 1st part of image that show this part will resize.

    Bottom and Right parts are for content padding, your content will reside in this part only(reserve your content area).

    You can see pink dotted box in the 2st part of image that show this part is for your content(string or etc).

    General standard to be follow given in below image.

    enter image description here

    Note: make 9patch of those image which having uniform color and shape(not complex curve).