Package icyllis.modernui.text.style
Class StyleSpan
java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.MetricAffectingSpan
icyllis.modernui.text.style.StyleSpan
- All Implemented Interfaces:
icyllis.modernui.text.ParcelableSpan,UpdateAppearance,UpdateLayout,Parcelable,Cloneable
Span that allows setting the style of the text it's attached to.
Possible styles are:
Typeface.NORMAL, Typeface.BOLD,
Typeface.ITALIC and Typeface.BOLD_ITALIC.
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.
For example, the StyleSpan can be used like this:
SpannableString string = new SpannableString("Bold and italic text");
string.setSpan(new StyleSpan(Typeface.BOLD), 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
string.setSpan(new StyleSpan(Typeface.ITALIC), 9, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-
Nested Class Summary
Nested classes/interfaces inherited from interface icyllis.modernui.util.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>, Parcelable.WriteFlags -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturn a special type identifier for this span class.intgetStyle()Returns the style constant defined inTextPaint.voidupdateMeasureState(TextPaint paint) Classes that extendMetricAffectingSpanimplement this method to update the text formatting in a way that can change the width or height of characters.voidwriteToParcel(Parcel dest, int flags) The subclass implements the method to flatten its contents by calling the methods ofParcelfor its primitive values.Methods inherited from class icyllis.modernui.text.style.MetricAffectingSpan
updateDrawStateMethods inherited from class icyllis.modernui.text.style.CharacterStyle
clone, wrap
-
Constructor Details
-
Method Details
-
getSpanTypeId
public int getSpanTypeId()Return a special type identifier for this span class.- Specified by:
getSpanTypeIdin interfaceicyllis.modernui.text.ParcelableSpan
-
writeToParcel
Description copied from interface:ParcelableThe subclass implements the method to flatten its contents by calling the methods ofParcelfor its primitive values.- Specified by:
writeToParcelin interfaceParcelable- Parameters:
dest- the parcel to write the object's data toflags- the flags about how the object should be written
-
getStyle
public int getStyle()Returns the style constant defined inTextPaint. -
updateMeasureState
Description copied from class:MetricAffectingSpanClasses that extendMetricAffectingSpanimplement this method to update the text formatting in a way that can change the width or height of characters.- Specified by:
updateMeasureStatein classMetricAffectingSpan- Parameters:
paint- the paint used for measuring the text
-