Code example for TextPaint

Methods: getTextSizemeasureText

            reqWidth = widthSize;
        } else { 
            // find out the total pixel size required for first and last text 
            reqWidth = (int)(strokePaint.measureText(getText().toString()))+10;
        // find out Height based on heightMode 
        if (heightMode == MeasureSpec.EXACTLY) {
            // set user specified Height 
            reqHeight = heightSize;
        } else { 
            // get the default height of the Font 
            reqHeight = (int) strokePaint.getTextSize();
        // set the calculated width and height of your drawing area 
        setMeasuredDimension(reqWidth, reqHeight+10);
Stop searching for code, let great code find you!  Add Codota to your java IDE