Package icyllis.modernui.text.style
Class AbsoluteSizeSpan
java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.MetricAffectingSpan
icyllis.modernui.text.style.AbsoluteSizeSpan
- All Implemented Interfaces:
icyllis.modernui.text.ParcelableSpan,UpdateAppearance,UpdateLayout,Parcelable,Cloneable
public class AbsoluteSizeSpan
extends MetricAffectingSpan
implements icyllis.modernui.text.ParcelableSpan
A span that changes the size of the text it's attached to.
For example, the size of the text can be changed to 55dp like this:
SpannableString string = new SpannableString("Text with absolute size span");
string.setSpan(new AbsoluteSizeSpan(55, true), 10, 23, Spanned.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
ConstructorsConstructorDescriptionAbsoluteSizeSpan(int size) Set the text size tosizephysical pixels.AbsoluteSizeSpan(int size, boolean scaled) Set the text size tosizephysical pixels, or tosizedevice-independent pixels ifscaledis true.AbsoluteSizeSpan(Parcel src) Creates anAbsoluteSizeSpanfrom a parcel. -
Method Summary
Modifier and TypeMethodDescriptionintgetSize()Get the text size.intReturn a special type identifier for this span class.booleanisScaled()Returns whether the size is in device-independent pixels or not, depending on thescaledflag passed inAbsoluteSizeSpan(int, boolean)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
-
AbsoluteSizeSpan
public AbsoluteSizeSpan(int size) Set the text size tosizephysical pixels. -
AbsoluteSizeSpan
public AbsoluteSizeSpan(int size, boolean scaled) Set the text size tosizephysical pixels, or tosizedevice-independent pixels ifscaledis true. -
AbsoluteSizeSpan
Creates anAbsoluteSizeSpanfrom a parcel.
-
-
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
-
getSize
public int getSize()Get the text size. This is in physical pixels ifisScaled()returns false or in device-independent pixels ifisScaled()returns true.- Returns:
- the text size, either in physical pixels or device-independent pixels.
- See Also:
-
isScaled
public boolean isScaled()Returns whether the size is in device-independent pixels or not, depending on thescaledflag passed inAbsoluteSizeSpan(int, boolean)- Returns:
trueif the size is in device-independent pixels,falseotherwise- See Also:
-
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
-