本文整理汇总了Java中android.text.style.CharacterStyle.updateDrawState方法的典型用法代码示例。如果您正苦于以下问题:Java CharacterStyle.updateDrawState方法的具体用法?Java CharacterStyle.updateDrawState怎么用?Java CharacterStyle.updateDrawState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.style.CharacterStyle
的用法示例。
在下文中一共展示了CharacterStyle.updateDrawState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import android.text.style.CharacterStyle; //导入方法依赖的package包/类
@Override
public void draw(@NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
// bitmapCanvas.drawColor(Color.GRAY, PorterDuff.Mode.CLEAR);
int color = /*paint instanceof TextPaint ? ((TextPaint) paint).bgColor :*/ paint.getColor();
bitmapCanvas.drawColor(color);
for (CharacterStyle style : styles) {
if (style instanceof ReplacementSpan) {
((ReplacementSpan) style).draw(bitmapCanvas, text, start, end, 0, top, y, bottom, paint);
} else if (paint instanceof TextPaint) {
style.updateDrawState((TextPaint) paint);
}
}
paint.setXfermode(xfermode);
bitmapCanvas.drawText(text, start, end, 0, y, paint);
canvas.drawBitmap(bitmap, x, 0, null);
}
示例2: setupFontMetrics
import android.text.style.CharacterStyle; //导入方法依赖的package包/类
private void setupFontMetrics(CharSequence text, int start, int end, FontMetricsInt fm, Paint p) {
txtPaint.set(p);
final CharacterStyle[] otherSpans = ((Spanned) text).getSpans(start, end, CharacterStyle.class);
for (CharacterStyle otherSpan : otherSpans) {
otherSpan.updateDrawState(txtPaint);
}
txtPaint.setTextSize(p.getTextSize());
if (fm != null) {
txtPaint.getFontMetricsInt(fm);
}
}
示例3: draw
import android.text.style.CharacterStyle; //导入方法依赖的package包/类
@Override
public void draw(@NonNull Rect outRect, @NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
for (CharacterStyle style : styles) {
if (style instanceof SupportSpan) {
((SupportSpan) style).draw(frame, canvas, text, start, end, x, top, y, bottom, paint);
} else if (style instanceof ReplacementSpan) {
((ReplacementSpan) style).draw(canvas, text, start, end, x, top, y, bottom, paint);
} else if (paint instanceof TextPaint) {
style.updateDrawState((TextPaint) paint);
}
}
}