public
abstract
class
DynamicDrawableSpan
extends ReplacementSpan
java.lang.Object | ||||
↳ | android.text.style.CharacterStyle | |||
↳ | android.text.style.MetricAffectingSpan | |||
↳ | android.text.style.ReplacementSpan | |||
↳ | android.text.style.DynamicDrawableSpan |
Known Direct Subclasses |
Constants | |
---|---|
int |
ALIGN_BASELINE
A constant indicating that the bottom of this span should be aligned with the baseline of the surrounding text. |
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. |
Fields | |
---|---|
protected
final
int |
mVerticalAlignment
|
Public constructors | |
---|---|
DynamicDrawableSpan()
|
Protected constructors | |
---|---|
DynamicDrawableSpan(int verticalAlignment)
|
Public methods | |
---|---|
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 |
Inherited methods | |
---|---|
From
class
android.text.style.ReplacementSpan
| |
From
class
android.text.style.MetricAffectingSpan
| |
From
class
android.text.style.CharacterStyle
| |
From
class
java.lang.Object
|
int ALIGN_BASELINE
A constant indicating that the bottom of this span should be aligned with the baseline of the surrounding text.
Constant Value: 1 (0x00000001)
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.
Constant Value: 0 (0x00000000)
DynamicDrawableSpan (int verticalAlignment)
Parameters | |
---|---|
verticalAlignment |
int :
one of ALIGN_BOTTOM or ALIGN_BASELINE .
|
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. |
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.
|
Drawable getDrawable ()
Your subclass must implement this method to provide the bitmap to be drawn. The dimensions of the bitmap must be the same from each call to the next.
Returns | |
---|---|
Drawable |
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. |
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. |
int getVerticalAlignment ()
Returns the vertical alignment of this span, one of ALIGN_BOTTOM
or
ALIGN_BASELINE
.
Returns | |
---|---|
int |