ReplacementSpan
abstract class ReplacementSpan : MetricAffectingSpan
Known Direct Subclasses
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.
|
|
Known Indirect Subclasses
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 methods |
abstract Unit |
Draws the span into the canvas.
|
open CharSequence? |
Gets a brief description of this ReplacementSpan for use in accessibility support.
|
abstract Int |
Returns the width of the span.
|
open Unit |
Sets the specific content description into ReplacementSpan.
|
open Unit |
This method does nothing, since ReplacementSpans are drawn explicitly instead of affecting Paint properties.
|
open Unit |
This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.
|
Inherited functions |
From class MetricAffectingSpan
MetricAffectingSpan! |
getUnderlying()
Returns "this" for most MetricAffectingSpans, but for MetricAffectingSpans that were generated by wrap , returns the underlying MetricAffectingSpan.
|
|
From class CharacterStyle
Unit |
updateDrawState(tp: TextPaint!)
|
CharacterStyle! |
wrap(cs: CharacterStyle!)
A given CharacterStyle can only applied to a single region of a given Spanned. If you need to attach the same CharacterStyle to multiple regions, you can use this method to wrap it with a new object that will have the same effect but be a distinct object so that it can also be attached without conflict.
|
|
Public constructors
ReplacementSpan
ReplacementSpan()
Public methods
draw
abstract fun draw(
canvas: Canvas,
text: CharSequence!,
start: Int,
end: Int,
x: Float,
top: Int,
y: Int,
bottom: Int,
paint: Paint
): Unit
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
open fun getContentDescription(): CharSequence?
Gets a brief description of this ReplacementSpan for use in accessibility support.
Return |
CharSequence? |
The content description. This value may be null . |
getSize
abstract fun getSize(
paint: Paint,
text: CharSequence!,
start: Int,
end: Int,
fm: Paint.FontMetricsInt?
): Int
Returns the width of the span. Extending classes can set the height of the span by updating attributes of android.graphics.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. |
Return |
Int |
Width of the span. |
setContentDescription
open fun setContentDescription(contentDescription: CharSequence?): Unit
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
open fun updateDrawState(ds: TextPaint!): Unit
This method does nothing, since ReplacementSpans are drawn explicitly instead of affecting Paint properties.
updateMeasureState
open fun updateMeasureState(p: TextPaint): Unit
This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.
Parameters |
textPaint |
the paint used for drawing the text This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[]]