Class Overview
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.
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, String srcName)
Create a drawable projection from a bitmap to nine patches.
|
[Expand]
Inherited Methods |
From class java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Is called before the object's memory is being reclaimed by the VM.
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of Class which represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
|
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
final
Region
getTransparentRegion
(Rect location)
public
final
boolean
hasAlpha
()
public
static
boolean
isNinePatchChunk
(byte[] chunk)
public
void
setPaint
(Paint p)