Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in API level 1

ReplacementSpan

public abstract class ReplacementSpan
extends MetricAffectingSpan

java.lang.Object
   ↳ android.text.style.CharacterStyle
     ↳ android.text.style.MetricAffectingSpan
       ↳ android.text.style.ReplacementSpan


Summary

Public constructors

ReplacementSpan()

Public methods

abstract void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)

Draws the span into the canvas.

abstract int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm)

Returns the width of the span.

void updateDrawState(TextPaint ds)

This method does nothing, since ReplacementSpans are drawn explicitly instead of affecting Paint properties.

void updateMeasureState(TextPaint p)

This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.

Inherited methods

Public constructors

ReplacementSpan

added in API level 1
public ReplacementSpan ()

Public methods

draw

added in API level 1
public abstract void draw (Canvas canvas, 
                CharSequence text, 
                int start, 
                int end, 
                float x, 
                int top, 
                int y, 
                int bottom, 
                Paint paint)

Draws the span into the canvas.

Parameters
canvas Canvas: Canvas into which the span should be rendered.

This value must never be null.

text CharSequence: Current text.

start int: Start character index for span.

end int: End character index for span.

x float: Edge of the replacement closest to the leading margin.

top int: Top of the line.

y int: Baseline.

bottom int: Bottom of the line.

paint Paint: Paint instance.

This value must never be null.

getSize

added in API level 1
public abstract int getSize (Paint paint, 
                CharSequence text, 
                int start, 
                int end, 
                Paint.FontMetricsInt fm)

Returns the width of the span. Extending classes can set the height of the span by updating attributes of Paint.FontMetricsInt. If the span covers the whole text, and the height is not set, draw(Canvas, CharSequence, int, int, float, int, int, int, Paint) will not be called for the span.

Parameters
paint Paint: Paint instance.

This value must never be null.

text CharSequence: Current text.

start int: Start character index for span.

end int: End character index for span.

fm Paint.FontMetricsInt: Font metrics, can be null.

Returns
int Width of the span.

updateDrawState

added in API level 1
public void updateDrawState (TextPaint ds)

This method does nothing, since ReplacementSpans are drawn explicitly instead of affecting Paint properties.

Parameters
ds TextPaint

updateMeasureState

added in API level 1
public void updateMeasureState (TextPaint p)

This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.

Parameters
p TextPaint: the paint used for drawing the text