Package icyllis.modernui.text.style
Class ImageSpan
- All Implemented Interfaces:
UpdateAppearance,UpdateLayout,Cloneable
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);
ImageSpans 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
ConstructorsConstructorDescriptionConstructs anImageSpanfrom aContextand anImagewith the default alignmentDynamicDrawableSpan.ALIGN_BOTTOMConstructs anImageSpanfrom a drawable with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM.Constructs anImageSpanfrom 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, getVerticalAlignmentMethods inherited from class icyllis.modernui.text.style.ReplacementSpan
updateMeasureStateMethods inherited from class icyllis.modernui.text.style.MetricAffectingSpan
updateDrawStateMethods inherited from class icyllis.modernui.text.style.CharacterStyle
clone, wrap
-
Constructor Details
-
ImageSpan
Deprecated.- Parameters:
image- image to be rendered
-
ImageSpan
Deprecated.- Parameters:
image- image to be renderedverticalAlignment- one ofDynamicDrawableSpan.ALIGN_BOTTOMorDynamicDrawableSpan.ALIGN_BASELINE
-
ImageSpan
Constructs anImageSpanfrom aContextand anImagewith 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_BOTTOMorDynamicDrawableSpan.ALIGN_BASELINE
-
ImageSpan
Constructs anImageSpanfrom a drawable with the default alignmentDynamicDrawableSpan.ALIGN_BOTTOM.- Parameters:
drawable- drawable to be rendered
-
ImageSpan
Constructs anImageSpanfrom a drawable and a vertical alignment.- Parameters:
drawable- drawable to be renderedverticalAlignment- one ofDynamicDrawableSpan.ALIGN_BOTTOMorDynamicDrawableSpan.ALIGN_BASELINE
-
-
Method Details
-
getDrawable
Description copied from class:DynamicDrawableSpanYour 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:
getDrawablein classDynamicDrawableSpan
-