Stretching using nine-patch images

There are times when you want a border that is more than a simple line, for example, if you want to add a shadow. On a web-page, you'll commonly find various HTML tricks used to insert eight or nine images into a box so that the content can be scaled while the border remains intact. In Android, this technique is called a "nine-patch" image because it consists of nine different parts. A nine-patch image in Android is handled specially when it's rendered at sizes larger than its original size. In order to identify these images as special, they have a .9.png extension (and must be valid PNG files).

A nine-patch image combines a border and a background in a single image. The background area will grow when the content ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.