您可以通过以下方式轻松实现:
// Load the image as a NinePatch drawableNinePatchDrawable npd = (NinePatchDrawable)Resources.getDrawable(R.drawable.my_nine_patch);// Set its bound where you needRect npdBounds = new Rect(...);npd.setBounds(npbBounds);// Finally draw on the canvasnpd.draw(canvas);



