Most visited

Recently visited

Added in API level 1

DynamicDrawableSpan

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


Summary

Constants

int ALIGN_BASELINE

一个常数,表示此跨度的底部应与周围文本的基线对齐。

int ALIGN_BOTTOM

一个常数,表示此跨度的底部应该与周围文本的底部对齐,即与文本中最低的下边距相同。

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)

将跨度绘制到画布上。

abstract Drawable getDrawable()

你的子类必须实现这个方法来提供要绘制的位图。

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

返回跨度的宽度。

int getVerticalAlignment()

返回此跨度的垂直对齐,即 ALIGN_BOTTOMALIGN_BASELINE

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

Constants

ALIGN_BASELINE

Added in API level 3
int ALIGN_BASELINE

一个常数,表示此跨度的底部应与周围文本的基线对齐。

常数值:1(0x00000001)

ALIGN_BOTTOM

Added in API level 3
int ALIGN_BOTTOM

一个常数,表示此跨度的底部应该与周围文本的底部对齐,即与文本中最低的下边距相同。

常量值:0(0x00000000)

Fields

mVerticalAlignment

Added in API level 3
int mVerticalAlignment

Public constructors

DynamicDrawableSpan

Added in API level 1
DynamicDrawableSpan ()

Protected constructors

DynamicDrawableSpan

Added in API level 3
DynamicDrawableSpan (int verticalAlignment)

Parameters
verticalAlignment int: one of ALIGN_BOTTOM or ALIGN_BASELINE.

Public methods

draw

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

将跨度绘制到画布上。

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.

getDrawable

Added in API level 1
Drawable getDrawable ()

你的子类必须实现这个方法来提供要绘制的位图。 每次调用时,位图的尺寸必须相同。

Returns
Drawable

getSize

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

返回跨度的宽度。 扩展类可以通过更新Paint.FontMetricsInt属性来设置跨度的高度。 如果跨度覆盖整个文本,并且未设置高度,则不会为跨度调用draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)

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.

getVerticalAlignment

Added in API level 3
int getVerticalAlignment ()

返回此跨度的垂直对齐,即 ALIGN_BOTTOMALIGN_BASELINE

Returns
int

Hooray!