Code example for Paint

Methods: getTextBounds

    // Draw text aligned correctly. 
	private void drawText(Canvas canvas, int i, String text, Paint p, boolean left){
		Rect bounds = new Rect();
		p.getTextBounds(text, 0, text.length(), bounds);
		float textHeight = p.getFontMetrics().bottom - p.getFontMetrics().top;
		float y = (float) (height/2.0 - (float)i * textHeight * 1.2f - textHeight*.2); 
		canvas.drawText(text, (float)(-width/2.0 + textHeight*.2f), y, p);
	private void drawGrid(Canvas canvas) {
		for(int vertical = 1; vertical<10; vertical++){
Connect your IDE to all the code out there  Get Codota for Java