实现代码
计算与定位
首先计算图片的位置(默认已获得到图片Bitmap对象)
Rect rect = new Rect();
rect.left = what you want
rect.top = what you want
rect.right = what you want
rect.bottom = what you want
绘制
Android提供了一个名为NinePatch工具类的专门绘制9Path文件
drawNinepath(canvas,mProgressHintBG,rect);
/**
* 绘制 9Path
* @param c
* @param bmp
* @param rect
*/
public void drawNinepath(Canvas c, Bitmap bmp, Rect rect){
NinePatch patch = new NinePatch(bmp, bmp.getNinePatchChunk(), null);
patch.draw(c, rect);
}