Methods Summary |
---|
public void | draw(Canvas canvas)
mNinePatch.draw(canvas, getBounds(), mPaint);
|
public int | getChangingConfigurations()
return super.getChangingConfigurations() | mNinePatchState.mChangingConfigurations;
|
public ConstantState | getConstantState()
mNinePatchState.mChangingConfigurations = super.getChangingConfigurations();
return mNinePatchState;
|
public int | getIntrinsicHeight()Retrieves the height of the source .png file (before resizing).
return mNinePatch.getHeight();
|
public int | getIntrinsicWidth()Retrieves the width of the source .png file (before resizing).
return mNinePatch.getWidth();
|
public int | getMinimumHeight()
return mNinePatch.getHeight();
|
public int | getMinimumWidth()
return mNinePatch.getWidth();
|
public int | getOpacity()Returns a {@link android.graphics.PixelFormat graphics.PixelFormat}
value of OPAQUE or TRANSLUCENT.
return mNinePatch.hasAlpha() || (mPaint != null && mPaint.getAlpha() < 255) ?
PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
|
public boolean | getPadding(Rect padding)
padding.set(mPadding);
return true;
|
public Paint | getPaint()
if (mPaint == null) {
mPaint = new Paint();
}
return mPaint;
|
public Region | getTransparentRegion()
return mNinePatch.getTransparentRegion(getBounds());
|
public void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
super.inflate(r, parser, attrs);
TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.NinePatchDrawable);
final int id = a.getResourceId(com.android.internal.R.styleable.NinePatchDrawable_src, 0);
if (id == 0) {
throw new XmlPullParserException(parser.getPositionDescription() +
": <nine-patch> requires a valid src attribute");
}
final boolean dither = a.getBoolean(
com.android.internal.R.styleable.NinePatchDrawable_dither, false);
final BitmapFactory.Options options = new BitmapFactory.Options();
if (dither) {
options.inDither = false;
}
final Rect padding = new Rect();
Bitmap bitmap = null;
try {
final TypedValue value = new TypedValue();
final InputStream is = r.openRawResource(id, value);
bitmap = BitmapFactory.decodeStream(r, value, is, padding, options);
is.close();
} catch (IOException e) {
// Ignore
}
if (bitmap == null) {
throw new XmlPullParserException(parser.getPositionDescription() +
": <nine-patch> requires a valid src attribute");
} else if (bitmap.getNinePatchChunk() == null) {
throw new XmlPullParserException(parser.getPositionDescription() +
": <nine-patch> requires a valid 9-patch source image");
}
setNinePatchState(new NinePatchState(
new NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"), padding, dither));
a.recycle();
|
public Drawable | mutate()
if (!mMutated && super.mutate() == this) {
mNinePatchState = new NinePatchState(mNinePatchState);
mNinePatch = mNinePatchState.mNinePatch;
mPadding = mNinePatchState.mPadding;
mMutated = true;
}
return this;
|
public void | setAlpha(int alpha)
getPaint().setAlpha(alpha);
|
public void | setColorFilter(ColorFilter cf)
getPaint().setColorFilter(cf);
|
public void | setDither(boolean dither)
getPaint().setDither(dither);
|
private void | setNinePatchState(android.graphics.drawable.NinePatchDrawable$NinePatchState state)
mNinePatchState = state;
mNinePatch = state.mNinePatch;
mPadding = state.mPadding;
if (state.mDither) setDither(state.mDither);
|