Package icyllis.modernui.text.style
Class ImageSpan
- All Implemented Interfaces:
UpdateAppearance
,UpdateLayout
Span that replaces the text it's attached to with a Text with
Drawable
that can be aligned with
the bottom or with the baseline of the surrounding text. The drawable can be constructed from
varied sources:
Image
- seeImageSpan(Image)
andImageSpan(Image, int)
Drawable
- seeImageSpan(Drawable, int)
DynamicDrawableSpan.ALIGN_BOTTOM
For example, an ImagedSpan
can be used like this:
SpannableString string = new SpannableString("Bottom: span.\nBaseline: span."); // using the default alignment: ALIGN_BOTTOM string.setSpan(new ImageSpan(this, R.mipmap.ic_launcher), 7, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); string.setSpan(new ImageSpan(this, R.mipmap.ic_launcher, DynamicDrawableSpan.ALIGN_BASELINE), 22, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ImageSpan
s aligned bottom and baseline.-
Nested Class Summary
Nested classes/interfaces inherited from class icyllis.modernui.text.style.DynamicDrawableSpan
DynamicDrawableSpan.AlignmentType
-
Field Summary
Fields inherited from class icyllis.modernui.text.style.DynamicDrawableSpan
ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, mVerticalAlignment
-
Constructor Summary
ConstructorDescriptionConstructs anImageSpan
from aContext
and anImage
with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM
Constructs anImageSpan
from a drawable with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM
.Constructs anImageSpan
from a drawable and a vertical alignment.Deprecated.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionYour subclass must implement this method to provide the bitmap to be drawn.Methods inherited from class icyllis.modernui.text.style.DynamicDrawableSpan
draw, getSize, getVerticalAlignment
Methods inherited from class icyllis.modernui.text.style.ReplacementSpan
updateMeasureState
Methods inherited from class icyllis.modernui.text.style.MetricAffectingSpan
getUnderlying, updateDrawState
Methods inherited from class icyllis.modernui.text.style.CharacterStyle
wrap
-
Constructor Details
-
ImageSpan
Deprecated.- Parameters:
image
- image to be rendered
-
ImageSpan
Deprecated.- Parameters:
image
- image to be renderedverticalAlignment
- one ofDynamicDrawableSpan.ALIGN_BOTTOM
orDynamicDrawableSpan.ALIGN_BASELINE
-
ImageSpan
Constructs anImageSpan
from aContext
and anImage
with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM
- Parameters:
context
- context used to create a drawable from based on the display metrics of the resourcesimage
- image to be rendered
-
ImageSpan
- Parameters:
context
- context used to create a drawable from image based on the display metrics of the resourcesimage
- image to be renderedverticalAlignment
- one ofDynamicDrawableSpan.ALIGN_BOTTOM
orDynamicDrawableSpan.ALIGN_BASELINE
-
ImageSpan
Constructs anImageSpan
from a drawable with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM
.- Parameters:
drawable
- drawable to be rendered
-
ImageSpan
Constructs anImageSpan
from a drawable and a vertical alignment.- Parameters:
drawable
- drawable to be renderedverticalAlignment
- one ofDynamicDrawableSpan.ALIGN_BOTTOM
orDynamicDrawableSpan.ALIGN_BASELINE
-
-
Method Details
-
getDrawable
Description copied from class:DynamicDrawableSpan
Your subclass must implement this method to provide the bitmap to be drawn. The dimensions of the bitmap must be the same from each call to the next.- Specified by:
getDrawable
in classDynamicDrawableSpan
-