本文整理匯總了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);
}
}
}