9-batch files

If an image file name ends with “.9″ just before the file extension, it is considered a ninepatch. NinePatch images are used by your application to allow Android automatic resizing of the image without losing the intended shape of the original image. NinePatch images can be created using the draw9patch application.

1. From a terminal, launch the draw9patch application from your SDK /tools directory.
-Using Windows, "/adt-bundle-windows-x86_64-20130522/sdk/tools/draw9patch.bat"

2. Go to File > Open 9-patch > Select the image file.

3. To edit the perimeter, simply draw the black lines. The black lines select the area that will be resized when the image has different sizes. This allows for the edges to remain the same size and to maintain the view.

The black lines are what we added, the pink is the area that will be resized, and the green lines is the area that won’t be resized. On the right side of the image you can see how the image will look in different sizes. (Adjust Patch scale if you would like to view larger or smaller images).

4. Save the image with .9.png extension and place the file in your project.

The NinePatch drawable is a standard PNG image that includes an extra 1-pixel-wide border. It must be saved with the extension .9.png, and saved into the res/drawable/ directory of your project.