FileDocCategorySizeDatePackage
DrawableMarginSpan.javaAPI DocAndroid 5.1 API2442Thu Mar 12 22:22:10 GMT 2015android.text.style

DrawableMarginSpan

public class DrawableMarginSpan extends Object implements LeadingMarginSpan, LineHeightSpan

Fields Summary
private android.graphics.drawable.Drawable
mDrawable
private int
mPad
Constructors Summary
public DrawableMarginSpan(android.graphics.drawable.Drawable b)

        mDrawable = b;
    
public DrawableMarginSpan(android.graphics.drawable.Drawable b, int pad)

        mDrawable = b;
        mPad = pad;
    
Methods Summary
public voidchooseHeight(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 voiddrawLeadingMargin(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();

        // XXX What to do about Paint?
        mDrawable.setBounds(ix, itop, ix+dw, itop+dh);
        mDrawable.draw(c);
    
public intgetLeadingMargin(boolean first)

        return mDrawable.getIntrinsicWidth() + mPad;