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
DynamicDrawableSpan Span that replaces the text it's attached to with a Drawable that can be aligned with the bottom or with the baseline of the surrounding text. 
ImageSpan Span that replaces the text it's attached to with a Drawable that can be aligned with the bottom or with the baseline of the surrounding text. 


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.

CharSequence getContentDescription()

Gets a brief description of this ReplacementSpan for use in accessibility support.

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

Returns the width of the span.

void setContentDescription(CharSequence contentDescription)

Sets the specific content description into ReplacementSpan.

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

MetricAffectingSpan getUnderlying()

Returns "this" for most MetricAffectingSpans, but for MetricAffectingSpans that were generated by CharacterStyle.wrap(CharacterStyle), returns the underlying MetricAffectingSpan.

abstract void updateMeasureState(TextPaint textPaint)

Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.

CharacterStyle getUnderlying()

Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by wrap(CharacterStyle), returns the underlying CharacterStyle.

abstract void updateDrawState(TextPaint tp)
static CharacterStyle wrap(CharacterStyle cs)

A given CharacterStyle can only applied to a single region of a given Spanned.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

ReplacementSpan

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 cannot be null.

text CharSequence: Current text.

start int: Start character index for span. Value is 0 or greater

end int: End character index for span. Value is 0 or greater

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 cannot be null.

getContentDescription

Added in API level 30
public CharSequence getContentDescription ()

Gets a brief description of this ReplacementSpan for use in accessibility support.

Returns
CharSequence The content description. This value may 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(android.graphics.Canvas, java.lang.CharSequence, int, int, float, int, int, int, android.graphics.Paint) will not be called for the span.

Parameters
paint Paint: Paint instance. This value cannot be null.

text CharSequence: Current text.

start int: Start character index for span. Value is 0 or greater

end int: End character index for span. Value is 0 or greater

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

Returns
int Width of the span.

setContentDescription

Added in API level 30
public void setContentDescription (CharSequence contentDescription)

Sets the specific content description into ReplacementSpan. ReplacementSpans are shared with accessibility services, but only the content description is available from them.

Parameters
contentDescription CharSequence: content description. The default value is null.

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 This value cannot be null.