Methods Summary |
---|
public void | draw(Canvas canvas)
if (mScaleState.mDrawable.getLevel() != 0)
mScaleState.mDrawable.draw(canvas);
|
public int | getChangingConfigurations()
return super.getChangingConfigurations()
| mScaleState.mChangingConfigurations
| mScaleState.mDrawable.getChangingConfigurations();
|
public ConstantState | getConstantState()
if (mScaleState.canConstantState()) {
mScaleState.mChangingConfigurations = super.getChangingConfigurations();
return mScaleState;
}
return null;
|
public Drawable | getDrawable()Returns the drawable scaled by this ScaleDrawable.
return mScaleState.mDrawable;
|
public int | getIntrinsicHeight()
return mScaleState.mDrawable.getIntrinsicHeight();
|
public int | getIntrinsicWidth()
return mScaleState.mDrawable.getIntrinsicWidth();
|
public int | getOpacity()
return mScaleState.mDrawable.getOpacity();
|
public boolean | getPadding(Rect padding)
// XXX need to adjust padding!
return mScaleState.mDrawable.getPadding(padding);
|
private static float | getPercent(android.content.res.TypedArray a, int name)
String s = a.getString(name);
if (s != null) {
if (s.endsWith("%")) {
String f = s.substring(0, s.length() - 1);
return Float.parseFloat(f) / 100.0f;
}
}
return -1;
|
public void | inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs)
super.inflate(r, parser, attrs);
int type;
TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.ScaleDrawable);
float sw = getPercent(a, com.android.internal.R.styleable.ScaleDrawable_scaleWidth);
float sh = getPercent(a, com.android.internal.R.styleable.ScaleDrawable_scaleHeight);
int g = a.getInt(com.android.internal.R.styleable.ScaleDrawable_scaleGravity, Gravity.LEFT);
Drawable dr = a.getDrawable(com.android.internal.R.styleable.ScaleDrawable_drawable);
a.recycle();
final int outerDepth = parser.getDepth();
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
dr = Drawable.createFromXmlInner(r, parser, attrs);
}
if (dr == null) {
throw new IllegalArgumentException("No drawable specified for <scale>");
}
mScaleState.mDrawable = dr;
mScaleState.mScaleWidth = sw;
mScaleState.mScaleHeight = sh;
mScaleState.mGravity = g;
if (dr != null) {
dr.setCallback(this);
}
|
public void | invalidateDrawable(Drawable who)
if (mCallback != null) {
mCallback.invalidateDrawable(this);
}
|
public boolean | isStateful()
return mScaleState.mDrawable.isStateful();
|
public Drawable | mutate()
if (!mMutated && super.mutate() == this) {
mScaleState.mDrawable.mutate();
mMutated = true;
}
return this;
|
protected void | onBoundsChange(Rect bounds)
final Rect r = mTmpRect;
int level = getLevel();
int w = bounds.width();
final int iw = 0; //mScaleState.mDrawable.getIntrinsicWidth();
if (mScaleState.mScaleWidth > 0) {
w -= (int) ((w - iw) * (10000 - level) * mScaleState.mScaleWidth / 10000);
}
int h = bounds.height();
final int ih = 0; //mScaleState.mDrawable.getIntrinsicHeight();
if (mScaleState.mScaleHeight > 0) {
h -= (int) ((h - ih) * (10000 - level) * mScaleState.mScaleHeight / 10000);
}
Gravity.apply(mScaleState.mGravity, w, h, bounds, r);
if (w > 0 && h > 0) {
mScaleState.mDrawable.setBounds(r.left, r.top, r.right, r.bottom);
}
|
protected boolean | onLevelChange(int level)
mScaleState.mDrawable.setLevel(level);
onBoundsChange(getBounds());
invalidateSelf();
return true;
|
protected boolean | onStateChange(int[] state)
boolean changed = mScaleState.mDrawable.setState(state);
onBoundsChange(getBounds());
return changed;
|
public void | scheduleDrawable(Drawable who, java.lang.Runnable what, long when)
if (mCallback != null) {
mCallback.scheduleDrawable(this, what, when);
}
|
public void | setAlpha(int alpha)
mScaleState.mDrawable.setAlpha(alpha);
|
public void | setColorFilter(ColorFilter cf)
mScaleState.mDrawable.setColorFilter(cf);
|
public boolean | setVisible(boolean visible, boolean restart)
mScaleState.mDrawable.setVisible(visible, restart);
return super.setVisible(visible, restart);
|
public void | unscheduleDrawable(Drawable who, java.lang.Runnable what)
if (mCallback != null) {
mCallback.unscheduleDrawable(this, what);
}
|