9patch是随文字大小可以缩放的图片。 定义了拉伸区域,则除拉伸区域可变外,其他区域保持原来的形状大小不变。
9patch 九宫格 9分图 它的四个角不作任何伸展,四个边分别只作水平和垂直伸展,中间部分则是水平跟垂直同时伸展,这就是著名的9-patch图,很多作背景的时候,一个很小像素数的图就可以无限的伸展为某控件背景。
一个九宫图是可伸缩的位图,在Android中将会根据视图所处位置来自适应调整成匹配视图长宽的图形。一个非常典型的例子就是Android按钮
-按钮必须根据文本描述自适应长度。一个标准的九宫图是包含额外1像素宽边框的png图片。它必须被保存以.9.png为后缀的图片文件中,并保存在工程
的res/drawable目录里。
A NinePatchDrawable graphic is a stretchable bitmap image, which Android
will automatically resize to accommodate the contents of the View in
which you have placed it as the background. An example use of a
NinePatch is the backgrounds used by standard Android buttons — buttons
must stretch to accommodate strings of various lengths. A 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 in