Example usage for android.graphics NinePatch NinePatch

List of usage examples for android.graphics NinePatch NinePatch

Introduction

In this page you can find the example usage for android.graphics NinePatch NinePatch.

Prototype

public NinePatch(Bitmap bitmap, byte[] chunk, String srcName) 

Source Link

Document

Create a drawable projection from a bitmap to nine patches.

Usage

From source file:Main.java

public static NinePatchDrawable createScalableDrawable(Bitmap pic) {
    NinePatch np = new NinePatch(pic, pic.getNinePatchChunk(), null);
    return new NinePatchDrawable(np);
}

From source file:Main.java

/** return NinePatchDrawable with give id
 * @param aContext//from  w w w.j  ava 2 s .  c  o m
 * @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;
}