mPaint.setColor(Color.RED); mPaint.setStyle(Paint.Style.FILL); // how to draw the text center on our square // centering in X is easy... use alignment (and X at midpoint) float x = 64/2; // centering in Y, we need to measure ascent/descent first float y = 64/2 - (mFontMetrics.ascent + mFontMetrics.descent)/2; canvas.drawText(src.length/2 + "", x, y, mPaint);