StyleSpanpublic class StyleSpan extends MetricAffectingSpan implements android.text.ParcelableSpanDescribes 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)
mStyle = style;
| public StyleSpan(android.os.Parcel src)
mStyle = src.readInt();
|
Methods Summary |
---|
private static void | apply(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 int | describeContents()
return 0;
| public int | getSpanTypeId()
return TextUtils.STYLE_SPAN;
| public int | getStyle()Returns the style constant defined in {@link android.graphics.Typeface}.
return mStyle;
| public void | updateDrawState(android.text.TextPaint ds)
apply(ds, mStyle);
| public void | updateMeasureState(android.text.TextPaint paint)
apply(paint, mStyle);
| public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mStyle);
|
|