Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.NinePatch; import android.graphics.drawable.NinePatchDrawable; public class Main { /** return NinePatchDrawable with give id * @param aContext * @param aNinePatchResourceId * @return */ public static NinePatchDrawable getNinePatchDrawable(Context aContext, int aNinePatchResourceId) { Bitmap bg = BitmapFactory.decodeResource(aContext.getResources(), aNinePatchResourceId); NinePatch np = new NinePatch(bg, bg.getNinePatchChunk(), null); NinePatchDrawable t9Patch = new NinePatchDrawable(aContext.getResources(), np); return t9Patch; } }