NinePatch


public class NinePatch
extends Object

java.lang.Object
   ↳ android.graphics.NinePatch


The NinePatch class permits drawing a bitmap in nine or more sections. Essentially, it allows the creation of custom graphics that will scale the way that you define, when content added within the image exceeds the normal bounds of the graphic. For a thorough explanation of a NinePatch image, read the discussion in the 2D Graphics document.

The Draw 9-Patch tool offers an extremely handy way to create your NinePatch images, using a WYSIWYG graphics editor.

Summary

Public constructors

NinePatch(Bitmap bitmap, byte[] chunk)

Create a drawable projection from a bitmap to nine patches.

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

Create a drawable projection from a bitmap to nine patches.

Public methods

void draw(Canvas canvas, Rect location, Paint paint)

Draws the NinePatch.

void draw(Canvas canvas, Rect location)

Draws the NinePatch.

void draw(Canvas canvas, RectF location)

Draws the NinePatch.

Bitmap getBitmap()

Returns the bitmap used to draw this NinePatch.

int getDensity()

Return the underlying bitmap's density, as per Bitmap.getDensity().

int getHeight()

Returns the intrinsic height, in pixels, of this NinePatch.

String getName()

Returns the name of this NinePatch object if one was specified when calling the constructor.

Paint getPaint()

Returns the paint used to draw this NinePatch.

final Region getTransparentRegion(Rect bounds)

Returns a Region representing the parts of the NinePatch that are completely transparent.

int getWidth()

Returns the intrinsic width, in pixels, of this NinePatch.

final boolean hasAlpha()

Indicates whether this NinePatch contains transparent or translucent pixels.

static boolean isNinePatchChunk(byte[] chunk)

Verifies that the specified byte array is a valid 9-patch data chunk.

void setPaint(Paint p)

Sets the paint to use when drawing the NinePatch.

Protected methods

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references