public abstract class DynamicDrawableSpan extends ReplacementSpan
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_BASELINE
A constant indicating that the bottom of this span should be aligned
with the baseline of the surrounding text.
|
static int |
ALIGN_BOTTOM
A constant indicating that the bottom of this span should be aligned
with the bottom of the surrounding text, i.e., at the same level as the
lowest descender in the text.
|
protected int |
mVerticalAlignment |
Modifier | Constructor and Description |
---|---|
|
DynamicDrawableSpan() |
protected |
DynamicDrawableSpan(int verticalAlignment) |
Modifier and Type | Method and Description |
---|---|
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 Drawable |
getDrawable()
Your subclass must implement this method to provide the bitmap
to be drawn.
|
int |
getSize(Paint paint,
CharSequence text,
int start,
int end,
Paint.FontMetricsInt fm)
Returns the width of the span.
|
int |
getVerticalAlignment()
Returns the vertical alignment of this span, one of
ALIGN_BOTTOM or
ALIGN_BASELINE . |
updateDrawState, updateMeasureState
getUnderlying
wrap
public static final int ALIGN_BOTTOM
public static final int ALIGN_BASELINE
protected final int mVerticalAlignment
public DynamicDrawableSpan()
protected DynamicDrawableSpan(int verticalAlignment)
verticalAlignment
- one of ALIGN_BOTTOM
or ALIGN_BASELINE
.public int getVerticalAlignment()
ALIGN_BOTTOM
or
ALIGN_BASELINE
.public abstract Drawable getDrawable()
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm)
ReplacementSpan
Paint.FontMetricsInt
. If the span covers the whole
text, and the height is not set,
ReplacementSpan.draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)
will not be
called for the span.getSize
in class ReplacementSpan
paint
- Paint instance.text
- Current text.start
- Start character index for span.end
- End character index for span.fm
- Font metrics, can be null.public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
ReplacementSpan
draw
in class ReplacementSpan
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.