Code example for TextPaint

Methods: ascent, descent

0
	private int measureHeight(int measureSpec) {
		int result = 0;
		int specMode = MeasureSpec.getMode(measureSpec);
		int specSize = MeasureSpec.getSize(measureSpec);
 
		mAscent = (int) mTextPaintOutline.ascent();
		if (specMode == MeasureSpec.EXACTLY) {
			result = specSize;
		} else { 
			result = (int) (-mAscent + mTextPaintOutline.descent()) + getPaddingTop() + getPaddingBottom();
			if (specMode == MeasureSpec.AT_MOST) {
				result = Math.min(result, specSize);
			} 
		} 
		return result;
	} 
 
	private TextPaint mTextPaint;
	private TextPaint mTextPaintOutline;
	private String mText = "";
	private int mAscent = 0;