FileDocCategorySizeDatePackage
StyleSpan.javaAPI DocAndroid 1.5 API2846Wed May 06 22:41:56 BST 2009android.text.style

StyleSpan

public class StyleSpan extends MetricAffectingSpan implements android.text.ParcelableSpan
Describes a style in a span. Note that styles are cumulative -- if both bold and italic are set in separate spans, or if the base style is bold and a span calls for italic, you get bold italic. You can't turn off a style from the base style.

Fields Summary
private final int
mStyle
Constructors Summary
public StyleSpan(int style)

param
style An integer constant describing the style for this span. Examples include bold, italic, and normal. Values are constants defined in {@link android.graphics.Typeface}.

		mStyle = style;
	
public StyleSpan(android.os.Parcel src)

        mStyle = src.readInt();
    
Methods Summary
private static voidapply(android.graphics.Paint paint, int style)

        int oldStyle;

        Typeface old = paint.getTypeface();
        if (old == null) {
            oldStyle = 0;
        } else {
            oldStyle = old.getStyle();
        }

        int want = oldStyle | style;

        Typeface tf;
        if (old == null) {
            tf = Typeface.defaultFromStyle(want);
        } else {
            tf = Typeface.create(old, want);
        }

        int fake = want & ~tf.getStyle();

        if ((fake & Typeface.BOLD) != 0) {
            paint.setFakeBoldText(true);
        }

        if ((fake & Typeface.ITALIC) != 0) {
            paint.setTextSkewX(-0.25f);
        }

        paint.setTypeface(tf);
    
public intdescribeContents()

        return 0;
    
public intgetSpanTypeId()

        return TextUtils.STYLE_SPAN;
    
public intgetStyle()
Returns the style constant defined in {@link android.graphics.Typeface}.

		return mStyle;
	
public voidupdateDrawState(android.text.TextPaint ds)

        apply(ds, mStyle);
    
public voidupdateMeasureState(android.text.TextPaint paint)

        apply(paint, mStyle);
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeInt(mStyle);