English | Site Directory

Android - An Open Handset Alliance Project

android.graphics
public class

android.graphics.NinePatch

java.lang.Object
android.graphics.NinePatch

The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes. Normally, the middle is transparent so that the patch can provide a selection about a rectangle.

Summary

Public Constructors

          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)
Draw a bitmap to nine patches.
        void  draw(Canvas canvas, Rect location, Paint paint)
Draw a bitmap to nine patches.
        void  draw(Canvas canvas, RectF location)
Draw a bitmap to nine patches.
        int  getHeight()
    final    Region  getTransparentRegion(Rect location)
        int  getWidth()
    final    boolean  hasAlpha()
      static  boolean  isNinePatchChunk(byte[] chunk)
        void  setPaint(Paint p)
Methods inherited from class java.lang.Object

Details

Public Constructors

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

Create a drawable projection from a bitmap to nine patches.

Parameters

bitmap The bitmap describing the patches.
chunk The 9-patch data chunk describing how the underlying bitmap is split apart and drawn.
srcName The name of the source for the bitmap. Might be null.

Public Methods

public void draw(Canvas canvas, Rect location)

Draw a bitmap to nine patches.

Parameters

canvas A container for the current matrix and clip used to draw the bitmap.
location Where to draw the bitmap.

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

Draw a bitmap to nine patches.

Parameters

canvas A container for the current matrix and clip used to draw the bitmap.
location Where to draw the bitmap.
paint The Paint to draw through.

public void draw(Canvas canvas, RectF location)

Draw a bitmap to nine patches.

Parameters

canvas A container for the current matrix and clip used to draw the bitmap.
location Where to draw the bitmap.

public int getHeight()

public final Region getTransparentRegion(Rect location)

public int getWidth()

public final boolean hasAlpha()

public static boolean isNinePatchChunk(byte[] chunk)

public void setPaint(Paint p)

Build m5-rc15g - 14 May 2008 12:50