Package icyllis.modernui.text.style
Class BackgroundColorSpan
java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.BackgroundColorSpan
- All Implemented Interfaces:
icyllis.modernui.text.ParcelableSpan,UpdateAppearance,Parcelable,Cloneable
public class BackgroundColorSpan
extends CharacterStyle
implements UpdateAppearance, icyllis.modernui.text.ParcelableSpan
Changes the background color of the text to which the span is attached.
For example, to set a green background color for a text you would create a SpannableString based on the text and set the span.
SpannableString string = new SpannableString("Text with a background color span");
string.setSpan(new BackgroundColorSpan(color), 12, 28, 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
ConstructorsConstructorDescriptionBackgroundColorSpan(int color) Creates aBackgroundColorSpanfrom a color integer.Creates aBackgroundColorSpanfrom a parcel. -
Method Summary
Modifier and TypeMethodDescriptionintintReturn a special type identifier for this span class.voidupdateDrawState(TextPaint paint) Updates the background color of the TextPaint.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.CharacterStyle
clone, wrap
-
Constructor Details
-
BackgroundColorSpan
Creates aBackgroundColorSpanfrom a color integer.- Parameters:
color- color integer that defines the background color
-
BackgroundColorSpan
Creates aBackgroundColorSpanfrom 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
-
getBackgroundColor
- Returns:
- the background color of this span.
- See Also:
-
updateDrawState
Updates the background color of the TextPaint.- Specified by:
updateDrawStatein classCharacterStyle
-