Code example for TextPaint

Methods: setColor, setTextSize, setTypeface

0
 
	private TextPaint getPaintFromHeap() {
		if (mPaintHeap.size() > 0)
			return mPaintHeap.remove(0);
		else 
			return new TextPaint(Paint.ANTI_ALIAS_FLAG);
	} 
 
	private HtmlObject getStyledObject(final StyleSpan span, final String content, final int start, final int end,
			final float thisXOffset) {
		final TextPaint paint = getPaintFromHeap();
		paint.setTypeface(Typeface.defaultFromStyle(span.getStyle()));
		paint.setTextSize(mTextSize);
		paint.setColor(mColor);
 
		span.updateDrawState(paint);
		span.updateMeasureState(paint);
		final HtmlObject obj = new HtmlObject(content, start, end, thisXOffset, paint);
		obj.recycle = true;
		return obj;
	}