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:
ParcelableSpan
,UpdateAppearance
,UpdateLayout
,Parcelable
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
ConstructorDescriptionAbsoluteSizeSpan
(int size) Set the text size tosize
physical pixels.AbsoluteSizeSpan
(int size, boolean scaled) Set the text size tosize
physical pixels, or tosize
device-independent pixels ifscaled
is true.AbsoluteSizeSpan
(Parcel src) Creates anAbsoluteSizeSpan
from a parcel. -
Method Summary
Modifier and TypeMethodDescriptionint
getSize()
Get the text size.int
Return a special type identifier for this span class.boolean
isScaled()
Returns whether the size is in device-independent pixels or not, depending on thescaled
flag passed inAbsoluteSizeSpan(int, boolean)
void
updateMeasureState
(TextPaint paint) Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.void
writeToParcel
(Parcel dest, int flags) The subclass implements the method to flatten its contents by calling the methods ofParcel
for its primitive values.Methods inherited from class icyllis.modernui.text.style.MetricAffectingSpan
getUnderlying, updateDrawState
Methods inherited from class icyllis.modernui.text.style.CharacterStyle
wrap
-
Constructor Details
-
AbsoluteSizeSpan
public AbsoluteSizeSpan(int size) Set the text size tosize
physical pixels. -
AbsoluteSizeSpan
public AbsoluteSizeSpan(int size, boolean scaled) Set the text size tosize
physical pixels, or tosize
device-independent pixels ifscaled
is true. -
AbsoluteSizeSpan
Creates anAbsoluteSizeSpan
from a parcel.
-
-
Method Details
-
getSpanTypeId
public int getSpanTypeId()Description copied from interface:ParcelableSpan
Return a special type identifier for this span class.- Specified by:
getSpanTypeId
in interfaceParcelableSpan
-
writeToParcel
Description copied from interface:Parcelable
The subclass implements the method to flatten its contents by calling the methods ofParcel
for its primitive values.- Specified by:
writeToParcel
in 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 thescaled
flag passed inAbsoluteSizeSpan(int, boolean)
- Returns:
true
if the size is in device-independent pixels,false
otherwise- See Also:
-
updateMeasureState
Description copied from class:MetricAffectingSpan
Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.- Specified by:
updateMeasureState
in classMetricAffectingSpan
- Parameters:
paint
- the paint used for measuring the text
-