Code example for TextPaint

Methods: ascentgetTextBounds

0
        mPaint.setStrokeCap(Paint.Cap.ROUND);
    } 
	 
	@Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		mTextPaint.getTextBounds(mText, 0, mText.length(), text_bounds);
        setMeasuredDimension( 
                measureWidth(widthMeasureSpec),
                measureHeight(heightMeasureSpec));
    } 
 
    private int measureWidth(int measureSpec) {
        int result = 0;
        int specMode = MeasureSpec.getMode(measureSpec);
        int specSize = MeasureSpec.getSize(measureSpec);
 
        if (specMode == MeasureSpec.EXACTLY) {
            // We were told how big to be 
            result = specSize;
        } else { 
            // Measure the text 
            result = Math.max(text_bounds.width(),mArrow.getWidth()) + (int)processBarWidth
            		+ getPaddingLeft() + getPaddingRight();
 
            if (specMode == MeasureSpec.AT_MOST) {
                // Respect AT_MOST value if that was what is called for by measureSpec 
                result = Math.min(result, specSize);
            } 
        } 
        return result;
    } 
 
    private int measureHeight(int measureSpec) {
        int result = 0;
        int specMode = MeasureSpec.getMode(measureSpec);
        int specSize = MeasureSpec.getSize(measureSpec);
 
        mAscent = (int) mTextPaint.ascent();
        if (specMode == MeasureSpec.EXACTLY) {
            // We were told how big to be 
            result = specSize;
        } else { 
            // Measure the text 
Contextual code suggestions in your IDE  Get Codota for Java