Package icyllis.modernui.text.style
Class ReplacementSpan
java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.MetricAffectingSpan
icyllis.modernui.text.style.ReplacementSpan
- All Implemented Interfaces:
UpdateAppearance,UpdateLayout,Cloneable
- Direct Known Subclasses:
DynamicDrawableSpan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddraw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, TextPaint paint) Draws the span into the canvas.abstract intgetSize(TextPaint paint, CharSequence text, int start, int end, FontMetricsInt fm) Returns the width of the span.final voidupdateMeasureState(TextPaint paint) This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.Methods inherited from class icyllis.modernui.text.style.MetricAffectingSpan
updateDrawStateMethods inherited from class icyllis.modernui.text.style.CharacterStyle
clone, wrap
-
Constructor Details
-
ReplacementSpan
public ReplacementSpan()
-
-
Method Details
-
updateMeasureState
This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.- Specified by:
updateMeasureStatein classMetricAffectingSpan- Parameters:
paint- the paint used for measuring the text
-
getSize
public abstract int getSize(@Nonnull TextPaint paint, CharSequence text, int start, int end, @Nullable FontMetricsInt fm) Returns the width of the span. Extending classes can set the height of the span by updating attributes ofFontMetricsInt. If the span covers the whole text, and the height is not set,draw(Canvas, CharSequence, int, int, float, int, int, int, TextPaint)will not be called for the span.- Parameters:
paint- Paint instance.text- Current text.start- Start character index for span.end- End character index for span.fm- Font metrics, can be null.- Returns:
- Width of the span.
-
draw
public abstract void draw(@Nonnull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @Nonnull TextPaint paint) Draws the span into the canvas.- Parameters:
canvas- Canvas into which the span should be rendered.text- Current text.start- Start character index for span.end- End character index for span.x- Edge of the replacement closest to the leading margin.top- Top of the line.y- Baseline.bottom- Bottom of the line.paint- Paint instance.
-