DrawableMarginSpanpublic class DrawableMarginSpan extends Object implements LeadingMarginSpan, LineHeightSpan
Fields Summary |
---|
private android.graphics.drawable.Drawable | mDrawable | private int | mPad |
Methods Summary |
---|
public void | chooseHeight(java.lang.CharSequence text, int start, int end, int istartv, int v, Paint.FontMetricsInt fm)
if (end == ((Spanned) text).getSpanEnd(this)) {
int ht = mDrawable.getIntrinsicHeight();
int need = ht - (v + fm.descent - fm.ascent - istartv);
if (need > 0)
fm.descent += need;
need = ht - (v + fm.bottom - fm.top - istartv);
if (need > 0)
fm.bottom += need;
}
| public void | drawLeadingMargin(android.graphics.Canvas c, android.graphics.Paint p, int x, int dir, int top, int baseline, int bottom, java.lang.CharSequence text, int start, int end, boolean first, android.text.Layout layout)
int st = ((Spanned) text).getSpanStart(this);
int ix = (int)x;
int itop = (int)layout.getLineTop(layout.getLineForOffset(st));
int dw = mDrawable.getIntrinsicWidth();
int dh = mDrawable.getIntrinsicHeight();
if (dir < 0)
x -= dw;
// XXX What to do about Paint?
mDrawable.setBounds(ix, itop, ix+dw, itop+dh);
mDrawable.draw(c);
| public int | getLeadingMargin(boolean first)
return mDrawable.getIntrinsicWidth() + mPad;
|
|