Code example for Paint

Methods: getTextSize, measureText, setColor

0
	 * @param canvas 
	 * @param pageNum 
	 */ 
	private void drawPageNum(Canvas canvas, int pageNum)
	{ 
		mTextPaint.setColor(Color.WHITE);
		String pageNumText = "- "+pageNum+" -";
		drawCentered(canvas, pageNumText,canvas.getHeight()-mTextPaint.getTextSize()-5,mTextPaint,mTextPaintShadow);
	} 
	 
	//--------------------------------------------------------------- 
	// Debug draw methods 
	//--------------------------------------------------------------- 
	 
	/** 
	 * Draw a text with a nice shadow 
	 */ 
	public static void drawTextShadowed(Canvas canvas, String text, float x, float y, Paint textPain, Paint shadowPaint) {
    	canvas.drawText(text, x-1, y, shadowPaint);
    	canvas.drawText(text, x, y+1, shadowPaint);
    	canvas.drawText(text, x+1, y, shadowPaint);
    	canvas.drawText(text, x, y-1, shadowPaint);    	
    	canvas.drawText(text, x, y, textPain);
    } 
	 
	/** 
	 * Draw a text with a nice shadow centered in the X axis 
	 * @param canvas 
	 * @param text 
	 * @param y 
	 * @param textPain 
	 * @param shadowPaint 
	 */ 
	public static void drawCentered(Canvas canvas, String text, float y, Paint textPain, Paint shadowPaint)
	{ 
		float posx = (canvas.getWidth() - textPain.measureText(text))/2;
		drawTextShadowed(canvas, text, posx, y, textPain, shadowPaint);
	} 
	 
	/** 
	 * Draw debug info